Class: MailEngine::MailLogSubscriber
- Inherits:
-
ActiveSupport::LogSubscriber
- Object
- ActiveSupport::LogSubscriber
- MailEngine::MailLogSubscriber
- Defined in:
- lib/mail_engine/mail_log_subscriber.rb
Overview
I don’t know if it’s a better solution, Seems below one is another good solution.
initializer "mail_engine.register_mail_log" do ActionMailer::Base.register_interceptor MailEngine::MailLog end
Instance Method Summary (collapse)
Instance Method Details
- (Object) deliver(event)
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/mail_engine/mail_log_subscriber.rb', line 22 def deliver(event) log_mail_config = MailEngine::Base.current_config["log_mail"] return false if log_mail_config.blank? or !log_mail_config MailEngine::MailLog.create!({ :mail_template_path => event.payload[:message_id], :subject => event.payload[:subject], :raw_body => event.payload[:mail], :recipient => event.payload[:to].inspect, :sender => event.payload[:from].inspect, :mime_type => event.payload[:mail].scan(/Content-Type: ([^;\r\n]*)/).flatten.inspect }) end |