Rails邮件程序从地址开始交替

时间:2014-10-16 17:43:04

标签: ruby-on-rails email ruby-on-rails-4 actionmailer

我可以在轨道中设置默认地址,如此;

    class UserMailer < ActionMailer::Base
      default :from => "\"Company\" <company@example.com>"

      def custom_address(user)
        # I want to set the from address here
        mail(to: user.email, subject: 'Custom from address')
      end
    end

但如何为其他方法设置自定义地址?我无法在文档

中的任何位置看到它

1 个答案:

答案 0 :(得分:1)

我可能错了,但我相信你可以在邮件方法中覆盖from。

class UserMailer < ActionMailer::Base
          default :from => "\"Company\" <company@example.com>"

          def custom_address(user)
            # I want to set the from address here
            mail(to: user.email, subject: 'Custom from address', from: 'asdf@other.com')
          end
        end