Sha256: 9e203bffeb9f70a49a83872ed19c4579b1af783b7b48b91144f4e954312305af
Contents?: true
Size: 1.57 KB
Versions: 3
Compression:
Stored size: 1.57 KB
Contents
class MailEngine::MailLog < ActiveRecord::Base validates_presence_of :mail_template_path # Callback of Mail gem when delivering mails def self.delivering_email mail # pp email.body.raw_source # pp email.to # pp email.from # pp email.subject # pp email.mime_type ################## # pp mail.mime_type # pp mail.content_type # pp mail.from #=> ['mikel@test.lindsaar.net', 'ada@test.lindsaar.net'] # pp mail.to #=> 'bob@test.lindsaar.net' # pp mail.subject #=> "This is the subject" # pp mail.body.decoded #=> 'This is the body of the email... ################### # pp mail.parts.map { |p| p.content_type } #=> ['text/plain', 'application/pdf'] # pp mail.parts.map { |p| p.class } #=> [Mail::Message, Mail::Message] # pp mail.parts[0].content_type_parameters #=> {'charset' => 'ISO-8859-1'} # pp mail.parts[1].content_type_parameters #=> {'name' => 'my.pdf'} # mail_type = email.header["X-mail-type"].value # record = create! :recipient => email.to.join(","), :mail_type => mail_type # email.encoded # kick email to set content_transfer_encoding # # The new body needs to be already encoded, as Mail expects the body to be encoded already (after calling #encoded) # encoding = Mail::Encodings.get_encoding email.content_transfer_encoding # new_body = encoding.encode email.body.to_s.sub("/t/id.gif", "/t/#{record.open_token}.gif") # email.body(new_body) # # record.update_attributes! :body => email.body.to_s, :raw_text => email.encoded end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
mail_engine-0.1.2 | app/models/mail_engine/mail_log.rb |
mail_engine-0.1.1 | app/models/mail_engine/mail_log.rb |
mail_engine-0.1.0 | app/models/mail_engine/mail_log.rb |