From 4d44be453c047df9548b1dd8aaba1b28858a74d4 Mon Sep 17 00:00:00 2001 From: Peter Giacomo Lombardo Date: Wed, 30 Aug 2023 19:26:53 +0200 Subject: [PATCH] Use a custom mailer for Reply-To support --- app/mailers/PWPushMailer.rb | 12 ++++++++++++ config/defaults/settings.yml | 4 ++++ config/initializers/devise.rb | 5 +++-- config/settings.yml | 4 ++++ 4 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 app/mailers/PWPushMailer.rb diff --git a/app/mailers/PWPushMailer.rb b/app/mailers/PWPushMailer.rb new file mode 100644 index 00000000000..082fb3cad15 --- /dev/null +++ b/app/mailers/PWPushMailer.rb @@ -0,0 +1,12 @@ +class PWPushMailer < Devise::Mailer + if Settings.mail + if Settings.mail.mailer_sender + default from: Settings.mail.mailer_sender + end + + if Settings.mail.mailer_reply_to + default reply_to: Settings.mail.mailer_reply_to + end + end +end + diff --git a/config/defaults/settings.yml b/config/defaults/settings.yml index b0ad22c81c3..92052f81cfc 100644 --- a/config/defaults/settings.yml +++ b/config/defaults/settings.yml @@ -713,6 +713,10 @@ mail: # Environment Variable Override: PWP__MAIL__MAILER_SENDER='"Password Pusher" ' # mailer_sender: '"Password Pusher" ' + # Configure the e-mail address which will be shown as 'Reply-To' in emails + # Environment Variable Override: PWP__MAIL__MAILER_REPLY_TO='"Password Pusher" ' + # mailer_reply_to: '"Password Pusher" ' + ### Feedback Form feedback: # The email that will receive the information filled out by users in the diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index 976affc0493..78ba12b2087 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -24,13 +24,14 @@ # Configure the e-mail address which will be shown in Devise::Mailer, # note that it will be overwritten if you use your own mailer class # with default "from" parameter. - config.mailer_sender = Settings.mail.mailer_sender if Settings.mail + # This is now configured in app/mailers/PWPushMailer.rb + # config.mailer_sender = Settings.mail.mailer_sender if Settings.mail # https://github.com/heartcombo/devise/issues/5439 config.navigational_formats = ['*/*', :html, :turbo_stream] # Configure the class responsible to send e-mails. - # config.mailer = 'Devise::Mailer' + config.mailer = 'PWPushMailer' # Configure the parent class responsible to send e-mails. # config.parent_mailer = 'ActionMailer::Base' diff --git a/config/settings.yml b/config/settings.yml index b0ad22c81c3..92052f81cfc 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -713,6 +713,10 @@ mail: # Environment Variable Override: PWP__MAIL__MAILER_SENDER='"Password Pusher" ' # mailer_sender: '"Password Pusher" ' + # Configure the e-mail address which will be shown as 'Reply-To' in emails + # Environment Variable Override: PWP__MAIL__MAILER_REPLY_TO='"Password Pusher" ' + # mailer_reply_to: '"Password Pusher" ' + ### Feedback Form feedback: # The email that will receive the information filled out by users in the