How to define a reply-to address?

Ruby on-Rails-3Actionmailer

Ruby on-Rails-3 Problem Overview


How can I define a reply-to address different than the :from one? Is that even possible?

Ruby on-Rails-3 Solutions


Solution 1 - Ruby on-Rails-3

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 - Ruby on-Rails-3

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionempzView Question on Stackoverflow
Solution 1 - Ruby on-Rails-3dogenpunkView Answer on Stackoverflow
Solution 2 - Ruby on-Rails-3laimisonView Answer on Stackoverflow