Module: TMail

### Home Classes Methods

### In Files

- 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/parser.rb
- lib/tmail/port.rb
- lib/tmail/utils.rb
- ext/tmailscanner/tmail/tmailscanner.c

### Namespace

- 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::Decoder
- CLASS TMail::DeleteFields
- CLASS TMail::Encoder
- CLASS TMail::EncryptedHeader
- CLASS TMail::FilePort
- CLASS TMail::HeaderField
- CLASS TMail::KeywordsHeader
- CLASS TMail::Mail
- CLASS TMail::Maildir
- CLASS TMail::MaildirLoader
- CLASS TMail::MaildirPort
- CLASS TMail::MboxLoader
- CLASS TMail::MessageIdHeader
- CLASS TMail::MhLoader
- CLASS TMail::MhMailbox
- CLASS TMail::MhPort
- CLASS TMail::MimeEncodeAuto
- CLASS TMail::MimeEncodeMulti
- CLASS TMail::MimeEncodeSingle
- CLASS TMail::MimeVersionHeader
- CLASS TMail::Parser
- 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::TMailScanner
- CLASS TMail::UNIXMbox
- CLASS TMail::UnstructuredHeader

### Methods

- ::new_boundary
- ::new_message_id
- #decoded
- #encoded
- #to_s

### Files

- CHANGES
- LICENSE
- NOTES
- README
- Rakefile
- MANIFEST
- Makefile
- depend
- Makefile
- COPYING
- README

### Class/Module Index

Quicksearch

- TMail
- TMail::Address
- TMail::AddressGroup
- TMail::AddressHeader
- TMail::Attachment
- TMail::ContentDispositionHeader
- TMail::ContentTransferEncodingHeader
- TMail::ContentTypeHeader
- TMail::DateTimeHeader
- TMail::EncryptedHeader
- TMail::FilePort
- TMail::HeaderField
- TMail::KeywordsHeader
- TMail::Mail
- TMail::MailFlags
- TMail::Maildir
- TMail::MaildirLoader
- TMail::MaildirPort
- TMail::MboxLoader
- TMail::MessageIdHeader
- TMail::MhLoader
- TMail::MhMailbox
- TMail::MhPort
- TMail::MimeVersionHeader
- TMail::Parser
- TMail::Port
- TMail::ReceivedHeader
- TMail::ReferencesHeader
- TMail::ReturnPathHeader
- TMail::SingleAddressHeader
- TMail::StringPort
- TMail::StructuredHeader
- TMail::SyntaxError
- TMail::TMailScanner
- TMail::TextUtils
- TMail::UNIXMbox
- TMail::UnstructuredHeader
- CharDet
- CharDet::Big5DistributionAnalysis
- CharDet::Big5Prober
- CharDet::CharDistributionAnalysis
- CharDet::CharSetGroupProber
- CharDet::CharSetProber
- CharDet::CodingStateMachine
- CharDet::EUCJPContextAnalysis
- CharDet::EUCJPDistributionAnalysis
- CharDet::EUCJPProber
- CharDet::EUCKRDistributionAnalysis
- CharDet::EUCKRProber
- CharDet::EUCTWDistributionAnalysis
- CharDet::EUCTWProber
- CharDet::EscCharSetProber
- CharDet::GB2312DistributionAnalysis
- CharDet::GB2312Prober
- CharDet::HebrewProber
- CharDet::JapaneseContextAnalysis
- CharDet::Latin1Prober
- CharDet::MBCSGroupProber
- CharDet::MultiByteCharSetProber
- CharDet::SBCSGroupProber
- CharDet::SJISContextAnalysis
- CharDet::SJISDistributionAnalysis
- CharDet::SJISProber
- CharDet::SingleByteCharSetProber
- CharDet::UTF8Prober
- CharDet::UniversalDetector

No matching classes.

# TMail

# 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.

### Constants

MaildirLoader
MboxLoader
MhLoader

### Public Class Methods

new_boundary() click to toggle source

Provides a new email boundary to separate parts of the email. This is a random string based off the current time, so should be fairly unique.

For Example:

    TMail.new_boundary
    #=> "mimepart_47bf656968207_25a8fbb80114"
    TMail.new_boundary
    #=> "mimepart_47bf66051de4_25a8fbb80240"

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

new_message_id( fqdn = nil ) click to toggle source

Provides a new email message ID. You can use this to generate unique email message id's for your email so you can track them.

Optionally takes a fully qualified domain name (default to the current hostname returned by Socket.gethostname) that will be appended to the message ID.

For Example:

    email.message_id = TMail.new_message_id
    #=> "<47bf66845380e_25a8fbb80332@baci.local.tmail>"
    email.to_s
    #=> "Message-Id: <47bf668b633f1_25a8fbb80475@baci.local.tmail>\n\n"
    email.message_id = TMail.new_message_id("lindsaar.net")
    #=> "<47bf668b633f1_25a8fbb80475@lindsaar.net.tmail>"
    email.to_s
    #=> "Message-Id: <47bf668b633f1_25a8fbb80475@lindsaar.net.tmail>\n\n"

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

### Public Instance Methods

decoded( eol = "\n", charset = 'e', dest = nil ) click to toggle source

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

    # 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

Also aliased as: to_s
encoded( eol = "\r\n", charset = 'j', dest = nil ) click to toggle source

Returns the TMail object encoded and ready to be sent via SMTP 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.

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

    # 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 ) click to toggle source
Alias for: decoded

[Validate]

Generated with the Darkfish Rdoc Generator 2.