Ruby on Rails : How to have conditional sender email address -
i using rails4, need change email address of action mailer based on condition. still takes default email address. how working?
class mailercontroller < actionmailer::base before_filter :get_tenant default from: "#{env['tenant_email']}" if $tenant == 'mytenant' def get_tenant $tenant = 'mytenant' end end
i have mailerclass inherits mailercontroller....
error: smtp address required send message. set message smtp_envelope_from, return_path, sender, or address.
my recommendation, change 'from' inside mail method.
def tenant? is_it_my_tenant_logic end def tenant? ? mailercontroller.default[:from] : "hiro@metaverse.com" end def a_mailer_method mail(:from => from, :to => "yt@realworld.com" , :subject => "i have logged in") end
Comments
Post a Comment