如何发送两个不同的电子邮件以进行可确认的设计和可确认的设计? [英] How to send two different emails for devise confirmable and devise reconfirmable?
本文介绍了如何发送两个不同的电子邮件以进行可确认的设计和可确认的设计?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
设计可确认(用户注册时为电子邮件确认)和可确认(用户更改电子邮件时为电子邮件确认)模块的模块均发送相同的电子邮件模板"confirmation_instructions".如何获取以便将其他电子邮件模板用于确认?
Both devise confirmable (email confirmation when user signs up) and reconfirmable (email confirmation when user changes email) modules send the same email template, "confirmation_instructions". How do I get it so that a different email template is used for confirmable?
推荐答案
您可以在邮件程序的 #confirmation_instructions
方法中覆盖 options [:template_name]
.>
You can override options[:template_name]
in the #confirmation_instructions
method of your mailer.
class AuthMailer < Devise::Mailer
helper :application
include Devise::Controllers::UrlHelpers
default template_path: 'devise/mailer'
def confirmation_instructions(record, token, options={})
# Use different e-mail templates for signup e-mail confirmation and for when a user changes e-mail address.
if record.pending_reconfirmation?
options[:template_name] = 'reconfirmation_instructions'
else
options[:template_name] = 'confirmation_instructions'
end
super
end
end
也请从device.rb更改此行
Also change this line from device.rb
# config.mailer = 'Devise::Mailer'
config.mailer = 'AuthMailer'
这篇关于如何发送两个不同的电子邮件以进行可确认的设计和可确认的设计?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文