1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
# frozen_string_literal: true
class DeviseMailer < Devise::Mailer
default from: "#{Gitlab.config.gitlab.email_display_name} <#{Gitlab.config.gitlab.email_from}>"
default reply_to: Gitlab.config.gitlab.email_reply_to
layout 'mailer/devise'
helper EmailsHelper
helper ApplicationHelper
helper RegistrationsHelper
include Gitlab::Email::SingleRecipientValidator
# Override devise_mail so that all emails, not just those redefined
# here, can only be sent to a single to: address.
def devise_mail(record, action, opts = {}, &block)
validate_single_recipient_in_opts!(opts)
super
end
def password_change_by_admin(record, opts = {})
devise_mail(record, :password_change_by_admin, opts)
end
def user_admin_approval(record, opts = {})
devise_mail(record, :user_admin_approval, opts)
end
def reset_password_instructions(record, token, opts = {})
headers['X-Mailgun-Suppressions-Bypass'] = 'true'
super
end
def email_changed(record, opts = {})
if Gitlab.com?
devise_mail(record, :email_changed_gitlab_com, opts)
else
devise_mail(record, :email_changed, opts)
end
end
protected
def subject_for(key)
subject = [super]
subject << Gitlab.config.gitlab.email_subject_suffix if Gitlab.config.gitlab.email_subject_suffix.present?
subject.join(' | ')
end
end
|