首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何重写mailboxer邮件程序

如何重写mailboxer邮件程序
EN

Stack Overflow用户
提问于 2014-09-10 15:55:01
回答 1查看 405关注 0票数 1

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

下面是邮件文件。谢谢你的指点。

代码语言:javascript
复制
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
EN

回答 1

Stack Overflow用户

发布于 2014-12-15 21:54:21

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

代码语言:javascript
复制
class MailboxerNotificationMailer < Mailboxer::BaseMailer
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25760103

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档