scinote-web/app/mailers/app_mailer.rb

38 lines
905 B
Ruby
Raw Normal View History

# frozen_string_literal: true
2016-07-21 19:11:15 +08:00
class AppMailer < Devise::Mailer
helper :application, :mailer, :input_sanitize
2016-07-21 19:11:15 +08:00
include Devise::Controllers::UrlHelpers
default template_path: 'users/mailer'
default from: ENV['MAIL_FROM']
default reply: ENV['MAIL_REPLYTO']
2016-07-21 19:11:15 +08:00
def notification(user_id, notification, opts = {})
@user = User.find(user_id)
2016-10-05 16:52:27 +08:00
@notification = notification
subject =
if notification.deliver?
2018-09-24 00:48:44 +08:00
I18n.t('notifications.deliver.email_subject')
else
2018-09-24 00:48:44 +08:00
I18n.t('notifications.email_title')
end
headers = {
to: @user.email,
subject: subject
2016-10-13 14:54:29 +08:00
}.merge(opts)
2016-10-05 16:52:27 +08:00
mail(headers)
end
2023-11-29 18:09:10 +08:00
def general_notification(opts = {})
@user = params[:recipient]
@notification = params[:record].to_notification
mail(
{
to: @user.email,
subject: I18n.t('notifications.email_title')
}.merge(opts)
)
end
2016-10-05 16:52:27 +08:00
end