Some of you might know about a little gem that Minero A. wrote called
tmail.
I took over maintenance of tmail in 2007 to scratch an itch… but I
found it difficult to add new features to.
So then I decided to write a mail library with the goal of providing a
simple, Ruby DSL on making emails. Make the simple, REALLY simple,
and make the complex possible. Taking a page from libmime library, I
decided to BDD a mail library… totally from the ground up. You can
find an entire references library in the source code and every spec
was written to handle a part of some RFC.
Also… I built it from the ground up to work with 1.8.6, 1.8.7 and
1.9.1. Mail passes all 747 examples in all three ruby’s.
So, in mail, right now in version 1.0.0 you can do this:
require ‘mail’
Mail.defaults do
smtp ‘127.0.0.1’ # Port 25 defult
end
mail = Mail.deliver do
to ‘[email protected]’
from ‘Mikel L. [email protected]’
subject ‘Multpart HTML Email Test’
text_part do
body %Q[Plain text body]
end
html_part do
content_type ‘text/html; charset=UTF-8’
body %Q[
Crazy cool HTML Body.
]
end
end
And you just sent a multipart HTML email.
You can also do this:
require ‘mail’
mail = Mail.read(‘/path/to/bounce_message.eml’)
mail.bounced? #=> true
mail.final_recipient #=> rfc822;[email protected]
mail.action #=> failed
mail.error_status #=> 5.5.0
mail.diagnostic_code #=> smtp;550 Requested action not taken:
mailbox unavailable
mail.retryable? #=> false
Anyway… as long as you have gemcutter installed and have tumble’d to
it, installing is:
gem install mail
If not:
gem sources -a http://gemcutter.org
gem install mail
Check out some more mail syntactic sugar at:
Note, this is a first release… I need lots of people to play, fork
and fix what they find.