Ruby on Mail

Replacement for TMail

Over the past months, I have sat down and written a brand new ruby mail program called, simply, Mail.

Mail is a Ruby Email Library and addresses many of the shortcomings of TMail. I have now completed the migration of the Rails ActionMailer module to use the Gem version of Mail instead of a vendor'd version of TMail and this has been merged back into the Rails master branch in preparation for Rails 3.0!

Having said all that, this site is still valid for TMail. Feel free to browse and send me any suggestions.

TMail - Ruby Email Handler

TMail is an email handler library for Ruby. TMail can extract data from mail, and write data to mail following the relevant RFCs on the subject.

You can get the latest version of TMail from the TMail RubyForge project or via Ruby Gems "tmail"

TMail is written in Ruby and a (very) small bit of supporting C that has pure ruby replacements if you can't compile on your computer. This means TMail will work, out of the box, on any platform that can run Ruby 1.8 or Ruby 1.9.

TMail is a commonly used library and is production ready. The ActionMailer component of Ruby on Rails uses it as well as the the Nitro web framework and many and others - including the Ruby-Talk mail gateway.

What TMail does is allow you to play with Emails like you would any Ruby object. So to change the To address of an email, instead of something like:

  my_message = "From\nReceived by.... etc"
  my_message.sub(/^To: .*?@.*?$/, "To:")

Which (a) will break easily and (b) is just not the Ruby-Way™ You can do:

  email = TMail::Mail.parse("From\nReceived by.... etc")
  email['to'] = ''

And TMail will take care of the details. Isn't that nicer?

TMail was created by Minero Aoki. It is currently maintained by Mikel and Trans as a RubyForge Project   .

For the impatient there is a quickstart guide that will get you up and running with TMail in a few minutes, for the rest, there is the full documentation by RDoc (comming soon) as well as an online user manual (needs updating).

Important Note For Rails and Nitro Users

If you are using the Rails or the Nitro Web Framework, and are reading this page, you probably know that your framework of choice uses TMail as it's email handler library already.

What you may not know, is that if you install the latest TMail gem, your library will use the latest Gem version. Nitro does this because it lists TMail as a dependency, Rails does this because since 2.0RC1, the ActionMailer section of Rails checks for a newer version of the TMail gem as it is loading up and if it finds a Gem version newer than 1.1.0, it will load the Gem version instead of the bundled version.

So to take advantage of the bug fixes, you can do:

$ sudo gem install tmail

And get the latest version installed (1.2) and your web framework will automatically update.

Rails 1.2 can not do this directly, but if you go to the TMail blog, I have written up how to patch ActionMailer 1.2.x to load the gem version of TMail in preference to the bundled version.


More TMail News...


Documentation is the focus of development right now, so be sure to check back with what is happening. Each new release adds some more documentation to the mix. If you want to help out, please let us know!

In the mean time, you can select from below, you can also always ask questions to the TMail-Talk Mailing list and we will do our best to answer.


If you want to help with the TMail project, please see our contributing to TMail page.

Right now we could do with a lot of documentation work, dive in and send your patches!

For the impatient, anonymous subversion repository is accessable via:

$ svn checkout tmail

Use the following links to view or sumbit Bugs, Patches and Feature Requests:

href=""> Submit a Patch