【发布时间】:2016-04-21 15:21:29
【问题描述】:
我正在尝试在 Rails 4 中制作应用程序。
在过去的 3 年里,我一直在努力找出设计/omniauth(我仍在努力让它发挥作用)。
抛开主要问题,当我尝试找到度过这个难关的意愿时,我尝试使用 Mandrill 设置电子邮件。
我找到了这个教程,我正在努力学习:https://nvisium.com/blog/2014/10/08/mandrill-devise-and-mailchimp-templates/
我有一个名为 mandrill_devise_mailer.rb 的邮件程序
class MandrillDeviseMailer < Devise::Mailer
def confirmation_instructions(record, token, opts={})
# code to be added here later
end
def reset_password_instructions(record, token, opts={})
options = {
:subject => "Reset your password",
:email => record.email,
:global_merge_vars => [
{
name: "password_reset_link",
# content: "http://www.example.com/users/password/edit?reset_password_token=#{token}"
content: "http://www.cr.com/users/password/edit?reset_password_token=#{token}"
},
{
name: "PASSWORD_RESET_REQUEST_FROM",
content: record.full_name
}
],
:template => "Forgot Password"
}
mandrill_send options
end
def unlock_instructions(record, token, opts={})
# code to be added here later
end
def mandrill_send(opts={})
message = {
:subject=> "#{opts[:subject]}",
:from_name=> "Reset Instructions",
# :from_email=>"example@somecorp.com",
:from_email=>["PROD_WELCOME"],
:to=>
[{"name"=>"#{opts[:full_name]}",
"email"=>"#{opts[:email]}",
"type"=>"to"}],
:global_merge_vars => opts[:global_merge_vars]
}
sending = MANDRILL.messages.send_template opts[:template], [], message
rescue Mandrill::Error => e
Rails.logger.debug("#{e.class}: #{e.message}")
raise
end
end
以上内容与他们在教程中所做的不同之处在于:
在我的邮件黑猩猩山魈模板中,我有:
<a href="*|password_reset_link|*">Change my password </a>
当我收到重置说明的电子邮件时,我会看到一个带下划线的链接,指向更改密码表单,上面写着“更改我的密码”。我希望“将我的密码更改为隐藏链接文本的标签”。
谁能看到我做错了什么?
【问题讨论】:
-
您的
:from_email设置为["PROD_WELCOME"],这在我看来不像是电子邮件地址。 -
谢谢 - 设置 ENV 使电子邮件发送,但它打印 || 之间的单词而不是拉入变量
-
也许您正在使用把手作为您的默认合并语言?转到设置下的 Mandrill sending options 并检查您是否启用了正确的合并语言。
-
嗨 Dylan,设置已设置为 Mailchimp。我把它们改成了车把,但预览仍然显示错误
-
很确定您不想要车把。您在上面使用的 mergetag 语法使用 Mailchimp 格式。
标签: ruby-on-rails email devise actionmailer mandrill