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

Share:
25,189
empz
Author by

empz

Updated on August 08, 2020

Comments