Customize the From address in Rails application

Posted by palani on Stack Overflow See other posts from Stack Overflow or by palani
Published on 2010-03-23T12:34:31Z Indexed on 2010/03/23 12:43 UTC
Read the original article Hit count: 228

Filed under:

Hi ,

I have mailer action in my application, the mailer is configured with gmail smtp. The following is my config details under environment.rb file

require "smtp_tls"
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.perform_deliveries = true
ActionMailer::Base.raise_delivery_errors = true
ActionMailer::Base.default_charset = "utf-8"
ActionMailer::Base.default_content_type = "text/html"

ActionMailer::Base.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => 'gmail.com',
:user_name => "[email protected]",
:password => "password",
:authentication => :plain

The think i want to implement is, when ever the application generating email the from address shows "[email protected]".

Is possible to customize the from address. In different places i want to use different From address instead of "[email protected]"

I tried with my mailer model:

@from = "#{user.email}"

In development server log it shows the customized id correctly. if go my email inbox it shows the from address as "[email protected]"

Can any one please guide on this. thanks in advance.

© Stack Overflow or respective owner

Related posts about ruby-on-rails