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 email@example.com\nReceived by.... etc" my_message.sub(/^To: .*?@.*?$/, "To: firstname.lastname@example.org")
Which (a) will break easily and (b) is just not the Ruby-Way™ You can do:
email = TMail::Mail.parse("From email@example.com\nReceived by.... etc") email['to'] = 'firstname.lastname@example.org'
And TMail will take care of the details. Isn't that nicer?
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.
- 15th of January, 2007 TMail Trunk is now compatible with Ruby 1.9 - Next release (1.2.2) will include this 1.9 compatibility, if you need this now, you can get it by getting the source code with 'svn checkout -r 197 http://tmail.rubyforge.org/svn/trunk/ TMail'
- 11th of January, 2007 New Release - 1.2.1 - Bug fixes on address handling as well as unix mailbox handling. More documentation and tests as well.
- 14th of December, 2007 New RDoc Put online - Fixed up and released a lot more examples and comments for the TMail::Mail class.
- 2nd of December, 2007 New Release - 1.2.0 - bug fixes for Attachments and the pure Ruby version of Scanner
- 19th of November, 2007 Create forward now returns a mail object in trunk
- 8th of November, 2007 New Release - 1.1.1 - bug fixes & Windows/Unix in one Gem
- 30th of October, 2007 New Release - 1.1.0 - Now a Gem!
- 24th of October, 2007 New Release - 0.11.0
- 23rd of October, 2007 TMail Talk Mailing List Created
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 http://tmail.rubyforge.org/svn/trunk/ tmail
Use the following links to view or sumbit Bugs, Patches and Feature Requests: