开发者

How to define a reply-to address?

开发者 https://www.devze.com 2023-03-02 22:19 出处:网络
How can I define a reply-to address different than the :from one? Is that even pos开发者_开发百科sible?Two ways:

How can I define a reply-to address different than the :from one? Is that even pos开发者_开发百科sible?


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 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:             'test@example.com'
  }
end

The reference:

https://guides.rubyonrails.org/action_mailer_basics.html#action-mailer-configuration

0

精彩评论

暂无评论...
验证码 换一张
取 消