【发布时间】:2012-11-22 09:11:13
【问题描述】:
我正在开发一个与 Mandrill(MailChimp 的事务性电子邮件服务)紧密集成的应用程序,我正在尝试覆盖 Devise Mailer,但由于某种原因,当我向 Mandrill 发送 API 调用时,我收到了他们的电子邮件,但 Devise 也给我发了一封电子邮件(这是空白的)。
这是我的DeviseMailer
class MyDeviseMailer < Devise::Mailer
def reset_password_instructions(record)
mandrill = Mandrill::API.new("#{MandrillConfig.api_key}")
mandrill.messages 'send-template',
{
:template_name => 'Forgot Password',
:template_content => "",
:message => {
:subject => "Forgot Password",
:from_email => "test@test123.com",
:from_name => "Company Support",
:to => [
{
:email => record.email
}
],
:global_merge_vars => [
{
:name => "FIRST_NAME",
:content => record.first_name
},
{
:name => "FORGOT_PASSWORD_URL",
:content => "<a href='#{edit_user_password_url(:reset_password_token => record.reset_password_token)}'>Change My Password</a>"
}
]
}
}
#We need to call super because Devise doesn't think we have sent any mail
super
end
end
我在这里找到了对super 的调用:http://qnundrum.com/answer.php?q=254917
【问题讨论】:
-
只是我想的,但是您是否尝试过覆盖 devise.rb 中的
config.mailer选项? -
我做到了,devise 仍在发送电子邮件,因为您必须在覆盖的底部调用 super
-
如果你忽略了对 super 的调用会发生什么?
-
我被这个问题困住了——你设法解决了吗?我正在考虑跳过
super并手动设置confirmation_sent_at,但我不确定它是否会起作用
标签: ruby-on-rails-3 devise actionmailer mailchimp