Class: DevMailInterceptor

Inherits:
Object
  • Object
show all
Defined in:
lib/myrails/templates/rails/app/mailers/dev_mail_interceptor.rb

Class Method Summary collapse

Class Method Details

.append_address_info(part, dev_text) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/myrails/templates/rails/app/mailers/dev_mail_interceptor.rb', line 17

def self.append_address_info(part, dev_text)
  case part.content_type
    when %r{^text/plain} then part.body = part.body.to_s + dev_text
    when %r{^text/html} then part.body = part.body.to_s + ("<pre>#{dev_text}</pre>").html_safe
  end
  part.parts.each { |p| append_address_info(p, dev_text)}
end

.delivering_email(message) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/myrails/templates/rails/app/mailers/dev_mail_interceptor.rb', line 4

def self.delivering_email(message)
  dev_text = "\n\n\n------------\n"
  dev_text += "To address is: #{message.to.to_a.join(", ")}\n"
  dev_text += "CC address is: #{message.cc.to_a.join(", ")}\n"
  dev_text += "BCC address is: #{message.bcc.to_a.join(", ")}\n"

  message.subject = "[#{Socket.gethostname}] [#{Rails.env}] #{message.subject}"
  message.to = '<%= @email %>'
  message.cc = ""
  message.bcc = ""
  append_address_info(message, dev_text)
end