class EventMachine::Protocols::SmtpClient

Simple SMTP client

@example

email = EM::Protocols::SmtpClient.send(
  :domain=>"example.com",
  :host=>'localhost',
  :port=>25, # optional, defaults 25
  :starttls=>true, # use ssl
  :from=>"sender@example.com",
  :to=> ["to_1@example.com", "to_2@example.com"],
  :header=> {"Subject" => "This is a subject line"},
  :body=> "This is the body of the email"
)
email.callback{
  puts 'Email sent!'
}
email.errback{ |e|
  puts 'Email failed!'
}

Sending generated emails (using Mail)

mail = Mail.new do
  from    'alice@example.com'
  to      'bob@example.com'
  subject 'This is a test email'
  body    'Hello, world!'
end

email = EM::P::SmtpClient.send(
  :domain=>'example.com',
  :from=>mail.from.first,
  :to=>mail.to,
  :message=>mail.to_s
)