简体   繁体   中英

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.

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. Eg 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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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