[Info] TMail included in ActionMailer differs from 'normal'


Just to hopefully save someone else a bunch of fun in the future - a
modified version of TMail is automatically installed with Rails in the
ActionMailer module. This version of TMail (which is required in your
rails environment by convention) differs significantly from the
package available at:


(Second hit on Google for ‘tmail’.)

At that site the author is very clear with where the division of labour

"What TMail is NOT

TMail does not touch mail body. Does not decode body, does not encode
body, does not change line terminator. (I want to support Base64
auto-decoding although.) "

However the vendor included version of TMail actually does decode the
body for you and silently performs automatic quoted-printable
conversion. Which, if you were previously developing your mail
handling functions outside of rails, you may have already implemented
yourself, with something like:

def decode_quoted_printable(text)
text.gsub(/\r\n/, “\n”).unpack(“M”).first

But if you run this over an already decoded string then you’ll lose
everything after the first equals sign. Which is probably not what
you wanted, especially if you’re dealing with text/html.

So if you’re trying, I don’t know, maybe to pull email in using
net/imap, slap it into a database and then present a web frontend to
that email then you’re probably better off starting from a rails
environment rather than evolving from a basic import script to a full
blown app.

Possible Solution:

  • Include TMail in the RDOC generation for http://api.rubyonrails.com/
  • Bump up the version number
    actionmailer-1.2.3/lib/action_mailer/vendor/tmail/info.rb or alter it
    somehow from the current ‘0.10.7’ (which is also, confusingly, a
    previous version of TMail)
  • Push the changes upstream so both version are reunited with standard



Paul W. schrieb:

  • Push the changes upstream so both version are reunited with standard