class Mail

Ruby on Rails 2.2.3

Since v2.2.3 Last seen in v2.3.18

Available in: v2.2.3 v2.3.18

Mail Class

Accessing a TMail object done via the TMail::Mail class. As email can be fairly complex creatures, you will find a large amount of accessor and setter methods in this class!

Most of the below methods handle the header, in fact, what TMail does best is handle the header of the email object. There are only a few methods that deal directly with the body of the email, such as base64_encode and base64_decode.

Using TMail inside your code

The usual way is to install the gem (see the README on how to do this) and then put at the top of your class:

require 'tmail'

You can then create a new TMail object in your code with:

@email = TMail::Mail.new

Or if you have an email as a string, you can initialize a new TMail::Mail object and get it to parse that string for you like so:

@email = TMail::Mail.parse(email_text)

You can also read a single email off the disk, for example:

@email = TMail::Mail.load('filename.txt')

Also, you can read a mailbox (usual unix mbox format) and end up with an array of TMail objects by doing something like this:

# Note, we pass true as the last variable to open the mailbox read only
mailbox = TMail::UNIXMbox.new("mailbox", nil, true)
@emails = []
mailbox.each_port { |m| @emails << TMail::Mail.new(m) }

Inherits from

Object

Includes

Constants

Attributes

Methods (defined here)

Private methods

(10) Implementation detail — not part of the public API.

Methods (inherited)

From Object (32)
From TMail::StrategyInterface (3)
From ActionController::Caching (3)
From ActionController::Cookies (2)
From ActionController::Flash (1)
From ActionController::HttpAuthentication::Basic::ControllerMethods (3)
From ActionController::RecordIdentifier (5)
From ActionController::RequestForgeryProtection (8)
From ActionController::Rescue (7)
From ActionController::Streaming (2)
From ActionController::Translation (4)
From ActiveRecord::Callbacks (14)
From ActiveRecord::Dirty (4)
From ActiveRecord::Locking::Pessimistic (1)
From ActiveRecord::NamedScope (1)
From ActiveRecord::Serialization (5)
From ActiveRecord::Transactions (4)
From ActiveRecord::Validations (7)
From Benchmark (1)
From ActionController::Components::InstanceMethods (2)
From ActiveRecord::Locking::Optimistic::ClassMethods (7)
From ActiveRecord::NamedScope::ClassMethods (2)
From ActiveRecord::Serialization::ClassMethods (1)
From ActiveRecord::Validations::ClassMethods (13)
From ActiveSupport::Memoizable (1)

Type at least 2 characters to search.

↑↓ navigate · open · esc close