Mel*_*Mel 8 email ruby-on-rails actionmailer devise mandrill
我正在尝试在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
Run Code Online (Sandbox Code Playgroud)
上述内容与本教程中的内容之间存在差异:
在我的邮件黑猩猩mandrill模板中,我有:
<a href="*|password_reset_link|*">Change my password </a>
Run Code Online (Sandbox Code Playgroud)
当我收到重置说明的电子邮件时,我会看到更改密码表单的带下划线的链接,其中显示"更改密码旁边的密码".我想'将我的密码更改为隐藏链接文本的标签'.
谁能看到我做错了什么?
Dmi*_*sky -2
这是我创建自定义 DeviseMailer 的方法
class MyDeviseMailer < Devise::Mailer
default template_path: 'devise/mailer' # to make sure that your mailer uses the devise views
def reset_password_instructions(record, token, opts={})
opts['from_email'] = "donotreply@mywebsite.com"
opts['from_name'] = "Password Reset"
#Rails.logger.mail.info "reset_password_instructions #{record.to_json} \n #{token.to_json} \n #{opts.to_json}"
super
end
end
Run Code Online (Sandbox Code Playgroud)
https://github.com/plataformatec/devise/wiki/How-To:-使用自定义邮件程序并 在设计电子邮件主题中添加动态值
| 归档时间: |
|
| 查看次数: |
585 次 |
| 最近记录: |