Module: MailRobber
- Defined in:
- lib/mail_robber.rb,
lib/mail_robber/config.rb,
lib/mail_robber/railtie.rb,
lib/mail_robber/version.rb,
lib/generators/mail_robber/install_generator.rb
Defined Under Namespace
Modules: Generators Classes: Configuration, Railtie
Constant Summary collapse
- VERSION =
"1.0.0"
Class Attribute Summary collapse
-
.config ⇒ Object
Returns the value of attribute config.
Class Method Summary collapse
Class Attribute Details
.config ⇒ Object
Returns the value of attribute config.
3 4 5 |
# File 'lib/mail_robber/config.rb', line 3 def config @config end |
Class Method Details
.configure {|config| ... } ⇒ Object
6 7 8 9 10 |
# File 'lib/mail_robber/config.rb', line 6 def self.configure self.config ||= Configuration.new yield(config) ActionMailer::Base.register_interceptor(MailRobber) end |
.delivering_email(message) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/mail_robber.rb', line 9 def self.delivering_email() params = { token: self.config.token, from: .from, to: .to, cc: .cc, bcc: .bcc, subject: .subject } if .multipart? # If message is HTML-only and has attachments, # it is considered multipart, but doesn't have # text_part, which is required by MailRobber params[:text_part] = .text_part.body.raw_source || .html_part.body.raw_source params[:html_part] = .html_part.body.raw_source if .html_part else case .mime_type when 'text/html' params[:text_part] = .body.raw_source params[:html_part] = .body.raw_source when 'text/plain' params[:text_part] = .body.raw_source end end = ..map do |a| { content_type: a.content_type, filename: a.filename, raw_source: a.body.raw_source } end params[:attachments] = Marshal::dump() intercept_letter(params) if self.config.enabled block_delivery() if self.config.block_delivery end |