铁轨 +设计=>全局使用 Devise Mailer 来处理所有邮件发送?

发布于 2024-12-17 07:33:54 字数 114 浏览 3 评论 0原文

我想在全球范围内使用设计邮件程序, 这样我就不必向我的应用程序添加另一个邮件程序,只需使用设计邮件程序即可在设计视图/控制器之外发送自定义邮件。

已经对此深感渴望,有人知道我如何才能做到这一点吗?

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.

Already digged to long for this, anyone know how I can make this possible?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

瀟灑尐姊 2024-12-24 07:33:54

如果重点是只有一个邮件程序,那么让您的一个邮件程序扩展 DeviseMailer 可能会更简单。例如,在应用程序/邮件程序中

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

  # add all your custom mailer methods
end

例如,此设置将导致所有电子邮件(来自 Devise 和其他方式)均使用 app/layouts/mailer.html.erb 模板发送。

请注意,要执行此操作,您确实需要将 Devise 邮件程序模板从 app/views/devise/mailer 移动到 app/views/mailer

If the point is to only have one mailer, it's perhaps more straightforward to have your one single mailer just extend the DeviseMailer. E.g. in 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.

Note that to do this you do need to move the Devise mailer templates from app/views/devise/mailer to just app/views/mailer.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文