Class: PonyExpress::Mail

Inherits:
Object
  • Object
show all
Includes:
PonyExpress
Defined in:
lib/pony-express.rb

Constant Summary

Constants included from PonyExpress

DEFAULT_SMTP_OPTIONS, TRANSPORTS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from PonyExpress

#build, #mail, #parse, #sendmail_binary, #sendmail_binary=, #transport_via_sendmail, transport_via_sendmail, #transport_via_smtp, transport_via_smtp

Constructor Details

#initialize(options = {}) ⇒ Mail

Returns a new instance of Mail.



106
107
108
# File 'lib/pony-express.rb', line 106

def initialize options = {}
  @options = options
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



104
105
106
# File 'lib/pony-express.rb', line 104

def options
  @options
end

Instance Method Details

#add(options) ⇒ Object

Add an option.

Examples:

add.

require "pony-express"
mail = PonyExpress::Mail.new
mail.add to: "[email protected]"


117
118
119
# File 'lib/pony-express.rb', line 117

def add options
  @options.merge! options
end

#contentObject

Return the encoded email content.



142
143
144
# File 'lib/pony-express.rb', line 142

def content
  build(@options)
end

#deliverObject



138
# File 'lib/pony-express.rb', line 138

def deliver; dispatch end

#dispatchObject

Send the email via the selected transport.



135
136
137
# File 'lib/pony-express.rb', line 135

def dispatch
  mail(@options)
end

#remove(keys) ⇒ Object

Remove an option.

Examples:

remove.

require "pony-express"
mail = PonyExpress::Mail.new
mail.add to: "[email protected]", cc: "[email protected]"
mail.remove :cc


128
129
130
131
# File 'lib/pony-express.rb', line 128

def remove keys
  keys = keys.map(&:to_sym)
  @options.reject! {|k, v| keys.include?(k) }
end