Module: MailLogger::Lib::Extensions::ActionMailer
- Defined in:
- lib/mail_logger/lib/extensions/action_mailer.rb
Class Method Summary collapse
Class Method Details
.included(base) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/mail_logger/lib/extensions/action_mailer.rb', line 5 def self.included(base) base.class_eval do def deliver_with_hooks!(*args) logger ||= nil mail = args.first || @mail # depend on ActionMailer::Base's @mail ivar is pretty nasty but has to be done if !mail.nil? begin logger.info "MailLogger logged #{mail.encoded}" if logger MailLog.create_from_mail(mail) rescue logger.info "MailLogger failed" if logger end end deliver_without_hooks!(*args) end alias_method_chain :deliver!, :hooks end end |