ActionMailer 中的多个默认发件人地址 Rails
Multiple default from address in ActionMailer Rails
下面是我从http://api.rubyonrails.org/
复制过来的正常格式
class ApplicationMailer < ActionMailer::Base
default from: 'from@example.com'
layout 'mailer'
end
但我想要的是能够发送多个地址。
我尝试调用一个方法,例如:
class ApplicationMailer < ActionMailer::Base
default from: address
layout 'mailer'
def address
Apartment::Tenant.current_tenant == "org" ? "custom@email.com" : "from@example.com"
end
end
当我调用该方法时 returns
<ActionMailer::Base::NullMail:0x007fbefe0eb388>
而不是我想要的字符串。
试试下面的代码:
class ApplicationMailer < ActionMailer::Base
default from: Apartment::Tenant.current_tenant == "org" ? "custom@email.com" : "from@example.com"
layout 'mailer'
end
下面是我从http://api.rubyonrails.org/
复制过来的正常格式class ApplicationMailer < ActionMailer::Base
default from: 'from@example.com'
layout 'mailer'
end
但我想要的是能够发送多个地址。
我尝试调用一个方法,例如:
class ApplicationMailer < ActionMailer::Base
default from: address
layout 'mailer'
def address
Apartment::Tenant.current_tenant == "org" ? "custom@email.com" : "from@example.com"
end
end
当我调用该方法时 returns
<ActionMailer::Base::NullMail:0x007fbefe0eb388>
而不是我想要的字符串。
试试下面的代码:
class ApplicationMailer < ActionMailer::Base
default from: Apartment::Tenant.current_tenant == "org" ? "custom@email.com" : "from@example.com"
layout 'mailer'
end