diff --git a/app/mailers/submitter_mailer.rb b/app/mailers/submitter_mailer.rb index 3a8c191bb..f8e59714c 100644 --- a/app/mailers/submitter_mailer.rb +++ b/app/mailers/submitter_mailer.rb @@ -185,8 +185,16 @@ class SubmitterMailer < ApplicationMailer assign_message_metadata('otp_verification_email', submitter) + from = + if Docuseal.multitenant? && + AccountConfig.exists?(account_id: submitter.account_id, key: 'custom_otp_email', value: true) + from_address_for_submitter(submitter) + else + default_params[:from] + end + I18n.with_locale(locale || submitter.account.locale) do - mail(to: submitter.email, subject: I18n.t('email_verification')) + mail(to: submitter.email, from:, subject: I18n.t('email_verification')) end end diff --git a/app/mailers/template_mailer.rb b/app/mailers/template_mailer.rb index bef49ba83..c92fb62f6 100644 --- a/app/mailers/template_mailer.rb +++ b/app/mailers/template_mailer.rb @@ -9,6 +9,16 @@ class TemplateMailer < ApplicationMailer assign_message_metadata('otp_verification_email', template) - mail(to: email, subject: I18n.t('email_verification')) + from = + if Docuseal.multitenant? && + AccountConfig.exists?(account_id: template.account_id, key: 'custom_otp_email', value: true) + put_metadata('from_user_id' => template.author_id) + + template.author.friendly_name + else + default_params[:from] + end + + mail(to: email, from:, subject: I18n.t('email_verification')) end end