# Mailer related query

**URL:** <https://www.ruby-forum.com/t/mailer-related-query/173769>\
**Category:** Rails\
**Created:** [August 14, 2009, 12:14pm UTC](https://www.ruby-forum.com/t/mailer-related-query/173769 "2009-08-14T12:14:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![hunt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/71e660/32.png) [@hunt](https://www.ruby-forum.com/u/hunt)\
**Post date:** [August 14, 2009, 12:14pm UTC](https://www.ruby-forum.com/t/mailer-related-query/173769/1 "2009-08-14T12:14:19Z")

</div>

## I am putting this in my mailer view…which sends message to some id. suppose removed\_email\_address@domain.invalid

Hi!  
You are having one email message from \<%= @email %\> with a title  
\<%= @title %\>  
and following is the message:  
 Confirm   
Thanks

* * *

On checking it on rediffmail or gmail server,

I am getting same thing

Hi!  
You are having one email message from \<%= @email %\> with a title  
\<%= @title %\>  
and following is the message:  
 Confirm   
Thanks

Not getting link to Confirm…

Don’t know why?

---

<div class="post-metadata">

**Author:** ![hunt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/71e660/32.png) [@hunt](https://www.ruby-forum.com/u/hunt)\
**Post date:** [August 14, 2009, 12:27pm UTC](https://www.ruby-forum.com/t/mailer-related-query/173769/2 "2009-08-14T12:27:16Z")

</div>

Do you get links on other than gmail or rediff?

Do you have action mailer instance under model folder? Have defined  
methods within it?

Here is a brief;

ruby script/generate mailer Notify

This should generate the following in your model directory and under  
folder in your view.

class Notify \< ActionMailer::Base  
end

now, you define methods with in models/notify.rb

class Notify \< ActionMailer::Base

def notifycustomer(blahh, blah)  
@subject = “Message from a visitor”  
@recipients = blahh.email  
@from = blah[:email]  
@sent\_on = Time.now  
@body[“title”] = blah[:msg]  
end  
end

in your controllers action you would trigger it

def sendmail2customer  
Notify.deliver\_notifycustomer(@blahh, params[:blah])  
end

in your view, you will have sendmail2customer.html.erb which might have

Hi!  
You are having one email message from \<%= @email %\> with a title  
\<%= @title %\>  
and following is the message:  
 Confirm   
Thanks

let me know how it goes

---

<div class="post-metadata">

**Author:** ![hunt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/71e660/32.png) [@hunt](https://www.ruby-forum.com/u/hunt)\
**Post date:** [August 14, 2009, 1:44pm UTC](https://www.ruby-forum.com/t/mailer-related-query/173769/3 "2009-08-14T13:44:33Z")

</div>

Rails L. wrote:

> Do you get links on other than gmail or rediff?
> 
> Do you have action mailer instance under model folder? Have defined  
> methods within it?
> 
> Here is a brief;
> 
> ruby script/generate mailer Notify
> 
> This should generate the following in your model directory and under  
> folder in your view.
> 
> class Notify \< ActionMailer::Base  
> end
> 
> now, you define methods with in models/notify.rb
> 
> class Notify \< ActionMailer::Base
> 
> def notifycustomer(blahh, blah)  
> @subject = “Message from a visitor”  
> @recipients = blahh.email  
> @from = blah[:email]  
> @sent\_on = Time.now  
> @body[“title”] = blah[:msg]  
> end  
> end
> 
> in your controllers action you would trigger it
> 
> def sendmail2customer  
> Notify.deliver\_notifycustomer(@blahh, params[:blah])  
> end
> 
> in your view, you will have sendmail2customer.html.erb which might have  
> ===============================================================================  
> Hi!  
> You are having one email message from \<%= @email %\> with a title  
> \<%= @title %\>  
> and following is the message:  
> Confirm   
> Thanks  
> =============================================================================  
> I am getting this  
> Hi!  
> You are having one email message from removed\_email\_address@domain.invalid with a title  
> Confirmation  
> and following is the message:  
> Confirm   
> Thanks

---

<div class="post-metadata">

**Author:** ![hunt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/71e660/32.png) [@hunt](https://www.ruby-forum.com/u/hunt)\
**Post date:** [August 14, 2009, 2:24pm UTC](https://www.ruby-forum.com/t/mailer-related-query/173769/4 "2009-08-14T14:24:17Z")

</div>

you have to replace the variables with your own

def notifycustomer(blahh, blah)  
@subject = “Message from a visitor”  
@recipients = blahh.email  
@from = blah[:email]  
@sent\_on = Time.now  
@body[“title”] = blah[:title] #now you can use @title in your view  
@body[“msg”] = blah[:msg] # now you can use @msg in your view  
@body[“url”] = “some url” # now you can use @url in your view  
end

if you have followed my sample code then your view should have

Hi!  
You are having one email message from \<%= @email %\> with a title  
\<%= @title %\>  
and following is the message:  
\<%= @msg %\>  
url: \<%= @url %\>

Thanks
