em-mailer
Simple wrapper for EventMachine SMTP client, makes sending mail with EM easy! It uses tmail or tmail-pure for creating the mail messages. tmail-pure has no C and works on JRuby. Grab it here github.com/yakischloba/tmail-pure/tree/master
If you want, you can just pass your own TMail::Mail object to Mailer#send instead of using the Mailer#mail helper. This would be useful for fancy things like attachments.
Synopsis
require 'rubygems'
require 'eventmachine'
require 'em-mailer'
mailer = EventMachine::Mailer.new(
:domain => 'somedomain.com',
:host => 'smtp.somemailserver.com',
:username => 'spaceman',
:password => 'afraidofasteroids',
)
# These callbacks will be executed for all mails sent with the mailer
mailer.callback { $stdout.puts "Sent successfully!"}
mailer.errback {|e| $stdout.puts "you blew it: #{e}"}
EM.run {
mailer.mail(
:to => "[email protected]",
:from => "[email protected]",
:subject => "zomg",
:body => "<html><body><h1>HEY</h1><p>Please don't hit me!</p></body></html>",
:html => true
)
}
Other options
# Set the port, defaults to 25.
:port => Integer
# Enable SSL on the connection. Note that this is just normal SSL,
# and not the STARTTLS command in the SMTP protocol.
:starttls => true/false
Issues
The EM client only supports ‘plain’ auth for now.