Mail

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.

On Oct 24, 2009, at 9:38 PM, Mikel L. wrote:

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.

Wow, I find this library very exciting! Thanks for sharing.

James Edward G. II

On Sun, Oct 25, 2009 at 3:19 PM, James Edward G. II
[email protected] wrote:

On Oct 24, 2009, at 9:38 PM, Mikel L. wrote:
Wow, I find this library very exciting! Â Thanks for sharing.

No problem.

The biggest area the library needs help is multibyte support.

In mail, everything is an object, and I have tried to keep class
responsibility well defined.

There is some code smell in there, especially the multibyte support,
so everyone, expect some changes between 1.0.0 and 1.1 on how things
get handled, there is more refactoring to do, but there are a lot of
specs to ensure code coverage.

Also, mail currently parses every email in the TMail test suite
without crashing, so that says something for reliability.

One more thing, in the announcement, I failed to mention the
contribution of Nicolas Fouché who put together the SMTP and POP3
wrappers.

Anyway, patches and code more than welcome… there are a lot of
edge cases in email.

Mikel

James Edward G. II wrote:

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.

Wow, I find this library very exciting! Thanks for sharing.

I will have to 2nd the motion, thanks for the mail gems Mikel

James Edward G. II


Kind Regards,
Rajinder Y.

http://DevMentor.org

Do Good! - Share Freely, Enrich and Empower people to Transform their
lives.

Great news!

Thanks for your work, I’ll surelly check it out.

On Mon, Oct 26, 2009 at 11:33 AM, botp [email protected] wrote:

On Sun, Oct 25, 2009 at 10:38 AM, Mikel L. [email protected] wrote:

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
indeed. amazingly rubyishly simple.
gem install mail
will  this be on rubyforge too?

Unfortunately I can’t register “mail” as a rubyforge gem. That’s why
it is on gemcutter

Mikel

On Sun, Oct 25, 2009 at 10:38 AM, Mikel L. [email protected]
wrote:

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

indeed. amazingly rubyishly simple.

gem install mail

will this be on rubyforge too?

thanks for mail.
kind regards -botp

Thanks for this work, I will check it out v soon, I am using net::smtp
at the moment! Can’t wait for things to be easier!

On 28/10/2009, at 2:11, Aldric G. [email protected] wrote:

Neat. Does it work with M$ Exchange ? (I know, I know - you said it
was
RFC /compliant/ …)

Heh, try it and let mr know… I mean it should :slight_smile:

Mikel

Mikel L. wrote:

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.

Neat. Does it work with M$ Exchange ? (I know, I know - you said it was
RFC /compliant/ …)

On Sat, Oct 24, 2009 at 10:38 PM, Mikel L. [email protected]
wrote:

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.

Nice work. Thanks Mikel.

-greg

Mikel L. wrote:

On 28/10/2009, at 2:11, Aldric G. [email protected] wrote:

Neat. Does it work with M$ Exchange ? (I know, I know - you said it
was
RFC /compliant/ …)

Heh, try it and let mr know… I mean it should :slight_smile:

Mikel

It works with Exchange :wink:
Have a (+1) * 1,000.

On 29/10/2009, at 4:53, Aldric G. [email protected] wrote:

So then I decided to write a mail library […]

Isn’t Tmail used by ActiveMailer ? If so, does that mean your ‘mail’
may
become part of Rails ?

It might well, mail works on ruby 1.9 and I know rails 3 is shooting
for 1.9 compat.

But mail is a different beast to tmail, having said that one person
has already expressed interest to rewrite actionmailer to use mail, it
would actually simplify a lot of the actionmailer code, but this is
just talk at the moment.

Mikel

Mikel L. wrote:

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 […]

Isn’t Tmail used by ActiveMailer ? If so, does that mean your ‘mail’ may
become part of Rails ?

On Oct 29, 2:26 am, Mikel L. [email protected] wrote:

It might well, mail works on ruby 1.9 and I know rails 3 is shooting
for 1.9 compat.

But mail is a different beast to tmail, having said that one person
has already expressed interest to rewrite actionmailer to use mail, it
would actually simplify a lot of the actionmailer code, but this is
just talk at the moment.

Mikel

I say thanks as well. Glad to see it!

Mike B.