如何覆盖邮箱邮件

时间:2014-09-10 07:55:01

标签: ruby-on-rails-4 mailboxer

我已经在我的mailers文件夹中自定义了notification_mailer.rb以使用Mandrill API,但是邮箱会忽略它并继续使用常规的smtp方法。我和Devise做了同样的事情,但Devise在其初始化文件管理器中有一个config.mailer。不是邮箱。

以下是邮件文件。谢谢指点。

class Mailboxer::NotificationMailer < Mailboxer::BaseMailer
#Sends and email for indicating a new notification to a receiver.
#It calls new_notification_email.

def mandrill_client
  require 'mandrill'
  @mandrill_client ||= Mandrill::API.new ENV['MANDRILL_APIKEY']
end


def send_email(notification, receiver)
  new_notification_email(notification, receiver)
end

#Sends an email for indicating a new message for the receiver
def new_notification_email(notification, receiver)
  @notification = notification
  @receiver     = receiver
  set_subject(notification)

  template_name = "new-notification-email-fr"
  template_content = []
  message = {
    to: [receiver.send(Mailboxer.email_method, notification)],
    subject: t('mailboxer.notification_mailer.subject', :subject => @subject),
    merge_vars: [
      {rcpt: receiver.send(Mailboxer.email_method, notification),
        vars: [
          ]
        }
      ]
    }
    mandrill_client.messages.send_template template_name, template_content, message
  end
end

1 个答案:

答案 0 :(得分:0)

我使用了错误的命名约定。应该是

class MailboxerNotificationMailer < Mailboxer::BaseMailer