Class: LeanMail::Deliver
- Inherits:
-
Object
- Object
- LeanMail::Deliver
- Defined in:
- contrib/lib/lean_mail.rb
Overview
Email deliverer.
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
-
#call(to, subject, body) ⇒ Deliver
Send email.
-
#initialize ⇒ Deliver
constructor
A new instance of Deliver.
Constructor Details
#initialize ⇒ Deliver
Returns a new instance of Deliver.
62 63 64 65 66 67 68 69 70 71 72 |
# File 'contrib/lib/lean_mail.rb', line 62 def initialize @user = ENV.fetch('SMTP_USER', nil) @password = ENV.fetch('SMTP_PASSWORD', nil) @from = ENV.fetch('SMTP_FROM') @host = ENV.fetch('SMTP_HOST') @port = ENV.fetch('SMTP_PORT', 25) @security = ENV.fetch('SMTP_SECURITY', nil) initialize_smtp end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
60 61 62 |
# File 'contrib/lib/lean_mail.rb', line 60 def data @data end |
Instance Method Details
#call(to, subject, body) ⇒ Deliver
Send email.
80 81 82 83 84 85 86 87 88 |
# File 'contrib/lib/lean_mail.rb', line 80 def call(to, subject, body) @data = Data.new(@from, to, subject, body) @smtp.start(Socket.gethostname, @user, @password, :plain) do |smtp| smtp.(@data.to_s, extract_addr(@from), extract_addrs(to)) end self end |