You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
1.1 KiB

  1. # frozen_string_literal: true
  2. class UserMailer < Devise::Mailer
  3. default from: ENV.fetch('SMTP_FROM_ADDRESS') { 'notifications@localhost' }
  4. layout 'mailer'
  5. helper :instance
  6. def confirmation_instructions(user, token, _opts = {})
  7. @resource = user
  8. @token = token
  9. @instance = Rails.configuration.x.local_domain
  10. I18n.with_locale(@resource.locale || I18n.default_locale) do
  11. mail to: @resource.unconfirmed_email.blank? ? @resource.email : @resource.unconfirmed_email, subject: I18n.t('devise.mailer.confirmation_instructions.subject', instance: @instance)
  12. end
  13. end
  14. def reset_password_instructions(user, token, _opts = {})
  15. @resource = user
  16. @token = token
  17. I18n.with_locale(@resource.locale || I18n.default_locale) do
  18. mail to: @resource.email, subject: I18n.t('devise.mailer.reset_password_instructions.subject')
  19. end
  20. end
  21. def password_change(user, _opts = {})
  22. @resource = user
  23. I18n.with_locale(@resource.locale || I18n.default_locale) do
  24. mail to: @resource.email, subject: I18n.t('devise.mailer.password_change.subject')
  25. end
  26. end
  27. end