How to define a reply-to address?
25,189
Solution 1
Two ways:
class Notifications < ActionMailer::Base
default :from => 'your_app@your_domain.com',
:reply_to => 'some_other_address@your_domain.com'
end
Or:
class Contacts < ActionMailer::Base
def new_contact
mail( :to => 'somebody@some_domain.com',
:from => 'your_app@your_domain.com',
:reply_to => 'someone_else@some_other_domain.com')
end
end
Or you can mix the two approaches. I'm sure there are even more ways to do this.
Solution 2
Solution for Rails 5.2 and possibly older/newer versions:
Amend the file:
config/environments/development.rb
With content:
Rails.application.configure do
config.action_mailer.default_options = {
reply_to: '[email protected]'
}
end
The reference:
https://guides.rubyonrails.org/action_mailer_basics.html#action-mailer-configuration
Author by
empz
Updated on August 08, 2020Comments
-
empz over 3 years
How can I define a reply-to address different than the
:from
one? Is that even possible? -
empz almost 13 yearsSilly boy, I've looked everywhere but the mail method definition: apidock.com/rails/ActionMailer/Base/mail Thank you!
-
user664833 almost 11 yearsThe official docs show this too: api.rubyonrails.org/classes/ActionMailer/…
-
Dan Barron over 9 yearsAccording to this: igvita.com/2007/07/21/sendmail-spam-filter-tricks-in-rails they should match, or your mail will get flagged by spam software.