Module TMail
In: lib/tmail/address.rb
lib/tmail/attachments.rb
lib/tmail/encode.rb
lib/tmail/header.rb
lib/tmail/interface.rb
lib/tmail/mail.rb
lib/tmail/mailbox.rb
lib/tmail/net.rb
lib/tmail/port.rb
lib/tmail/quoting.rb
lib/tmail/utils.rb

TMail - The EMail Swiss Army Knife for Ruby

The TMail library provides you with a very complete way to handle and manipulate EMails from within your Ruby programs.

Used as the backbone for email handling by the Ruby on Rails and Nitro web frameworks as well as a bunch of other Ruby apps including the Ruby-Talk mailing list to newsgroup email gateway, it is a proven and reliable email handler that won‘t let you down.

Originally created by Minero Aoki, TMail has been recently picked up by Mikel Lindsaar and is being actively maintained. Numerous backlogged bug fixes have been applied as well as Ruby 1.9 compatibility and a swath of documentation to boot.

TMail allows you to treat an email totally as an object and allow you to get on with your own programming without having to worry about crafting the perfect email address validation parser, or assembling an email from all it‘s component parts.

TMail handles the most complex part of the email - the header. It generates and parses headers and provides you with instant access to their innards through simple and logically named accessor and setter methods.

TMail also provides a wrapper to Net/SMTP as well as Unix Mailbox handling methods to directly read emails from your unix mailbox, parse them and use them.

Following is the comprehensive list of methods to access TMail::Mail objects. You can also check out TMail::Mail, TMail::Address and TMail::Headers for other lists.

Methods

Classes and Modules

Module TMail::MailFlags
Module TMail::TextUtils
Class TMail::AddDate
Class TMail::AddMessageId
Class TMail::Address
Class TMail::AddressGroup
Class TMail::AddressHeader
Class TMail::Attachment
Class TMail::ContentDispositionHeader
Class TMail::ContentTransferEncodingHeader
Class TMail::ContentTypeHeader
Class TMail::DateTimeHeader
Class TMail::DeleteFields
Class TMail::EncryptedHeader
Class TMail::FilePort
Class TMail::HeaderField
Class TMail::KeywordsHeader
Class TMail::Mail
Class TMail::Maildir
Class TMail::MaildirPort
Class TMail::MessageIdHeader
Class TMail::MhMailbox
Class TMail::MhPort
Class TMail::MimeEncodeAuto
Class TMail::MimeEncodeMulti
Class TMail::MimeEncodeSingle
Class TMail::MimeVersionHeader
Class TMail::Port
Class TMail::ReceivedHeader
Class TMail::ReferencesHeader
Class TMail::ReturnPathHeader
Class TMail::SingleAddressHeader
Class TMail::StringPort
Class TMail::StructuredHeader
Class TMail::SyntaxError
Class TMail::UNIXMbox
Class TMail::Unquoter
Class TMail::UnstructuredHeader

Constants

MhLoader = MhMailbox
MboxLoader = UNIXMbox
MaildirLoader = Maildir

Public Class methods

[Source]

# File lib/tmail/utils.rb, line 58
  def TMail.new_boundary
    'mimepart_' + random_tag
  end

[Source]

# File lib/tmail/utils.rb, line 62
  def TMail.new_message_id( fqdn = nil )
    fqdn ||= ::Socket.gethostname
    "<#{random_tag()}@#{fqdn}.tmail>"
  end

Public Instance methods

Returns the TMail object decoded and ready to be used by you, your program etc.

You should call this before you are packaging up your email to correctly escape all the values that need escaping in the email, line wrap the email etc.

For Example:

 email = TMail::Load(my_email_file)
 email_to_send = email.encoded

[Source]

# File lib/tmail/encode.rb, line 88
    def decoded( eol = "\n", charset = 'e', dest = nil )
      # Turn the E-Mail into a string and return it with all
      # encoded characters decoded.  alias for to_s
      accept_strategy Decoder, eol, charset, dest
    end

You should call this before you are packaging up your email to correctly escape all the values that need escaping in the email, line wrap the email etc.

It is also a good idea to call this before you marshal or serialize a TMail object.

For Example:

 email = TMail::Load(my_email_file)
 email_to_send = email.encoded

[Source]

# File lib/tmail/encode.rb, line 73
    def encoded( eol = "\r\n", charset = 'j', dest = nil )
      accept_strategy Encoder, eol, charset, dest
    end
to_s( eol = "\n", charset = 'e', dest = nil )

Alias for decoded

[Validate]