Closed dvodvo closed 1 year ago
The right thing to do is to define your own mailer and configure devise to use it using Devise.mailer=
.
Something like this should be more than enough:
class MyMultiTenantMailer < Devise::Mailer
default from: -> { my_dynamic_method_to_get_the_from }, reply_to: -> { my_dynamic_method_to_get_the_reply_to }
end
Devise.mailer = "MyMultiTenantMailer"
Current behavior
the initializer value for mail.from and mail.reply_to cannot be over-ridden. Or at the very least documentation for this is hard to find. Which is problematic for multi-tenant applications with distinct domains that are nonetheless all covered by SPF, DKIM and DMARC procedures covering the postfix send_only server.
It took quite a while until I stumbled upon this mechanism (see first line below) to set the url by altering the default
create
action ofpasswords_controller.rb
But I fail to wrangle a way to set the from and reply_to addresses. The auto-generated text help
is of use if one uses a distinct mailer class. But this is not the case here. Nor should it be required. A one-liner should be sufficient here (and more succinct than to generate a whole new mailer.)
What would the proper syntax be?