Class: Em::Smtp::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/em/smtp/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(values) ⇒ Client

Returns a new instance of Client.



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/em/smtp/client.rb', line 6

def initialize(values)
  self.settings = {
    host:     'localhost',
    port:     25,   # optional, defaults 25
    starttls: true, # use ssl
    domain:   'localhost.localdomain',
    #auth:     {
    #            type:     nil, # :plain
    #            username: nil, # 'username'
    #            password: nil  # 'password'
    #          }
  }.merge!(values)
end

Instance Attribute Details

#settingsObject

Returns the value of attribute settings.



20
21
22
# File 'lib/em/smtp/client.rb', line 20

def settings
  @settings
end

Instance Method Details

#deliver!(mail) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/em/smtp/client.rb', line 22

def deliver!(mail)
  email = EM::Protocols::SmtpClient.send(settings.merge!({
    to:       mail[:to].formatted,
    from:     mail[:from].addresses[0],
    content:  "#{mail.encoded}\r\n.\r\n"
  }))
  # Ignore callbacks now XD
  #email.callback{
  #}
  #email.errback{ |e|
  #}
end