Class: Hookworm::Emailer

Inherits:
Object
  • Object
show all
Defined in:
lib/hookworm/emailer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(email_uri, helo = 'localhost') ⇒ Emailer

Returns a new instance of Emailer.



8
9
10
11
# File 'lib/hookworm/emailer.rb', line 8

def initialize(email_uri, helo = 'localhost')
  @email_uri = URI(email_uri)
  @helo = helo
end

Instance Attribute Details

#email_uriObject (readonly)

Returns the value of attribute email_uri.



6
7
8
# File 'lib/hookworm/emailer.rb', line 6

def email_uri
  @email_uri
end

#heloObject (readonly)

Returns the value of attribute helo.



6
7
8
# File 'lib/hookworm/emailer.rb', line 6

def helo
  @helo
end

Instance Method Details

#send_email(from, to, msg) ⇒ Object



13
14
15
16
17
18
# File 'lib/hookworm/emailer.rb', line 13

def send_email(from, to, msg)
  Net::SMTP.start(*smtp_args) do |smtp|
    smtp.enable_ssl if email_uri.scheme == 'smtps'
    smtp.send_message(msg, from, to)
  end
end