Skip to content

Instantly share code, notes, and snippets.

@trevorturk
Created February 25, 2011 17:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trevorturk/844117 to your computer and use it in GitHub Desktop.
Save trevorturk/844117 to your computer and use it in GitHub Desktop.
# config/initializers/email_logger.rb
class EmailLogger
def self.delivered_email(email)
EmailLog.create!(
:from => email.from,
:to => email.to,
:subject => email.subject,
:body => email.body.inspect,
:date => email.date
)
end
Mail.register_observer(EmailLogger)
# app/models/email_log.rb
class EmailLog
include Mongoid::Document
field :from, :type => Array
field :to, :type => Array
field :subject
field :body
field :date, :type => DateTime
end
@synth
Copy link

synth commented May 4, 2013

you are missing a closing end to the delivered_email method ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment