我可以在轨道中设置默认地址,如此;
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
但如何为其他方法设置自定义地址?我无法在文档
中的任何位置看到它答案 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