我正在尝试在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,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,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>
当我收到重置说明的电子邮件时,我会看到更改密码表单的带下划线的链接,其中显示“更改密码旁边的密码”.我想’将我的密码更改为隐藏链接文本的标签’.
谁能看到我做错了什么?
解决方法
这是我创建自定义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,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
https://github.com/plataformatec/devise/wiki/How-To:-Use-custom-mailer和
Add dynamic value in devise email subject
原文地址:https://www.jb51.cc/ruby/269938.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。