2019-08-18 14:51:37 +02:00
|
|
|
class ApplicationMailer < ActionMailer::Base
|
|
|
|
|
layout 'mailer'
|
2022-07-18 10:47:54 +02:00
|
|
|
helper :application
|
2024-01-13 07:16:30 +13:00
|
|
|
|
|
|
|
|
after_action :set_mail_from_for_multitenancy
|
|
|
|
|
|
2024-05-03 18:11:07 +02:00
|
|
|
def set_mail_from_for_multitenancy
|
|
|
|
|
if Rails.application.multi_tenancy?
|
2024-05-09 19:23:45 +02:00
|
|
|
from = "#{Current.tenant.site_name} <#{ENV.fetch('EMAIL_MAIL_FROM', 'notifications@astuto.io')}>"
|
|
|
|
|
|
|
|
|
|
# Set a specific 'from' for the Devise::Mailer#confirmation_instructions method on tenant signup
|
|
|
|
|
if self.class.name == "Devise::Mailer" && action_name == "confirmation_instructions" && Current.tenant.users.count == 1
|
|
|
|
|
from = "Astuto <#{ENV.fetch('EMAIL_MAIL_FROM', 'notifications@astuto.io')}>"
|
|
|
|
|
end
|
|
|
|
|
|
2024-05-03 18:11:07 +02:00
|
|
|
mail.from = from
|
2024-01-13 07:16:30 +13:00
|
|
|
end
|
2024-05-03 18:11:07 +02:00
|
|
|
end
|
2019-08-18 14:51:37 +02:00
|
|
|
end
|