简体   繁体   English

Rails + Devise =>全局使用Devise Mailer来处理所有邮件发送吗?

[英]Rails + Devise => Use Devise Mailer globally to handle all of the mail sending?

I would like to use the devise mailer globally, since that way I would not have to add another mailer to my app and just use the devise one, to send custom mails outside the devise views/controllers. 我想在全球范围内使用devise邮件程序,因为这样一来,我不必在我的应用程序中添加另一个邮件程序,而只需使用devise邮件程序即可在devise视图/控制器外部发送自定义邮件。

Already digged to long for this, anyone know how I can make this possible? 已经深入研究,有人知道如何才能实现这一目标吗?

If the point is to only have one mailer, it's perhaps more straightforward to have your one single mailer just extend the DeviseMailer. 如果重点是只有一个邮件程序,则仅扩展一个DeviseMailer可能更直接。 Eg in app/mailer 例如在app / mailer中

# app/mailers/mailer.rb
class Mailer < Devise::Mailer

  # add all your custom mailer methods
end

This setup will, for example, cause all emails (from Devise and otherwise) to all be sent with the app/layouts/mailer.html.erb template. 例如,此设置将导致所有电子邮件(来自Devise和其他地方)都与app/layouts/mailer.html.erb模板一起发送。

Note that to do this you do need to move the Devise mailer templates from app/views/devise/mailer to just app/views/mailer . 请注意,要做到这一点,您确实需要将Devise邮件模板从app/views/devise/mailer移至app/views/mailer

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM