Sender Email

37 views
Skip to first unread message

Daynthan Kabilan

unread,
Feb 14, 2014, 6:12:22 AM2/14/14
to rubyonra...@googlegroups.com
Hi Friends,

how to add current user's email address for sender email using actionmailer.

example
mail(:to => user.email, :subject => "Thank you.", :from => "a...@gmail.com")

James Davis, PhD

unread,
Feb 14, 2014, 10:18:29 AM2/14/14
to rubyonra...@googlegroups.com
  Would you happen to be using Devise?  If so, there is a current_user helper for accessing the user that is currently logged in. 

def thanks_message
mail to: user.email, subject: "Thank you.", from: current_user.email
 end 

Frederick Cheung

unread,
Feb 14, 2014, 1:05:22 PM2/14/14
to rubyonra...@googlegroups.com
Al

On Friday, February 14, 2014 3:18:29 PM UTC, James Davis, PhD wrote:

example
mail(:to => user.email, :subject => "Thank you.", :from => "a...@gmail.com")

  Would you happen to be using Devise?  If so, there is a current_user helper for accessing the user that is currently logged in. 

def thanks_message
mail to: user.email, subject: "Thank you.", from: current_user.email
 end 

 Although do note that this may cause your messages to be flagged as spam (because most domains use DKIM/SPF to specify which mail servers are authorized to send mail on their behalf, and in general you won't be authorized to send email from the user's domain.


Fred

Daynthan Kabilan

unread,
Feb 17, 2014, 12:31:04 AM2/17/14
to rubyonra...@googlegroups.com
Thanks for your reply,

i want to add current user's email address in our default :from in user mailer




--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/f9be9988-32ac-4ba2-9b60-e5a8e2dd83f9%40googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages