class Mail
Ruby on Rails 2.2.3
Since v2.2.3 Last seen in v2.3.18Available 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
Includes
Constants
Attributes
Methods (defined here)
- # []
- # []=
- # accept
- # add_date
- # add_message_id
- # attachment?
- # attachments
- # base64_decode
- # base64_decode!
- # base64_encode
- # base64_encode!
- # bcc
- # bcc=
- # bcc_addrs
- # bcc_addrs=
- # body
- # body=
- # body_port
- # cc
- # cc=
- # cc_addrs
- # cc_addrs=
- # charset
- # charset=
- # clear
- # content_disposition
- # content_disposition=
- # content_transfer_encoding
- # content_transfer_encoding=
- # content_type
- # content_type=
- # content_type_is_text?
- # create_forward
- # create_reply
- # date
- # date=
- # delete
- # delete_if
- # delete_no_send_fields
- # destinations
- # disposition
- # disposition=
- # disposition_is_attachment?
- # disposition_param
- # each
- # each_dest
- # each_destination
- # each_field
- # each_header
- # each_header_name
- # each_key
- # each_pair
- # each_part
- # each_value
- # encoding
- # encoding=
- # epilogue
- # epilogue=
- # error_reply_addresses
- # fetch
- # friendly_from
- # from
- # from=
- # from_addr
- # from_address
- # from_address=
- # from_addrs
- # from_addrs=
- # from_phrase
- # has_attachments?
- # has_key?
- # has_value?
- # header
- # header_string
- # include?
- # indexes
- # indices
- # in_reply_to
- # in_reply_to=
- # inspect
- # key?
- # keys
- # main_type
- # message_id
- # message_id=
- # mime_encode
- # mime_encode_binary
- # mime_encode_multipart
- # mime_encode_singlepart
- # mime_encode_text
- # mime_version
- # mime_version=
- # msgid
- # msgid=
- # multipart?
- # ordered_each
- # parts
- # preamble
- # preamble=
- # quoted_body
- # quoted_body=
- # quoted_subject
- # ready_to_send
- # references
- # references=
- # reply_addresses
- # reply_to
- # reply_to=
- # reply_to_addrs
- # reply_to_addrs=
- # sender
- # sender=
- # sender_addr
- # sender_addr=
- # send_text_to
- # send_to
- # send_to_0
- # set_content_disposition
- # set_content_type
- # set_disposition
- # store
- # strftime
- # sub_header
- # subject
- # subject=
- # sub_type
- # to
- # to=
- # to_addrs
- # to_addrs=
- # transfer_encoding
- # transfer_encoding=
- # type_param
- # unquoted_body
- # value?
- # values
- # values_at
- # write_back
- self. boundary
- self. load
- self. load_from
- self. loadfrom
- self. msgid
- self. parse
Private methods
(10)
Implementation detail — not part of the public API.
- # add_hf
- # canonical
- # do_send_to
- # new_hf
- # parse_body
- # parse_body_0
- # parse_header
- # read_multipart
- # skip_header
- # with_multipart_encoding
Methods (inherited)
From Object (32)
- # acts_like?
- # app
- # blank?
- # class_eval
- # create
- # create_fixtures
- # duplicable?
- # edit
- # find_cmd
- # helper
- # index
- # instance_exec
- # instance_variable_defined?
- # instance_variable_names
- # message
- # metaclass
- # new_session
- # present?
- # reload!
- # returning
- # start_debugger
- # tail
- # to_json
- # to_param
- # to_query
- # unescape
- # update
- # with_options
- self. blank_slate_method_added
- self. find_hidden_method
- self. lookup_missing_generator
- self. method_added
From TMail::StrategyInterface (3)
From ActionController::Caching (3)
- # cache
- self. cache_configured?
- self. cache_store=
From ActionController::Cookies (2)
From ActionController::Flash (1)
- self. included
From ActionController::RecordIdentifier (5)
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)
- # lock!
From ActiveRecord::NamedScope (1)
- self. included
From ActiveRecord::Transactions (4)
From ActiveRecord::Validations (7)
From ActiveRecord::NamedScope::ClassMethods (2)
- # named_scope
- # scopes
From ActiveRecord::Validations::ClassMethods (13)
From ActiveSupport::Memoizable (1)
- # memoize