TMail::Mail class

Super Class

Object

Class Methods

new( arg ) : TMail::Mail
creates a new TMail::Mail object from port. "arg" is an TMail::Port object.
load( filename ) : TMail::Mail
creates a new TMail::Mail object. FILENAME is the name of file which contains only one mail (e.g. Mh mail file).
parse( str ) : TMail::Mail
parse string STR and creates a new TMail::Mail object.

Method

encoded( eol = "\r\n", charset = 'j', dest = '', sep = '' )
converts mail to an encoded string and write it to DEST using "<<" method. If there's ASCII ESC in header, TMail encode the header (only 'B' encode can be used).

SEP is a separator between header and body. ex: '----' for Mh mail.

decoded( eol = "\n", charset = 'e', dest = '', sep = '' )
converts mail to a decoded string and write it to DEST using "<<" method.

SEP is a separator between header and body. ex: '----' for Mh mail.

Now to_s is alias of this method.

body
preamble
the mail body. If the mail was MIME multipart mail, this represent 'preamble'.
parts
If the mail was MIME multipart mail, each element is TMail::Mail object which represents MIME part. If not, this is an empty array.
epilogue
If the mail was MIME multipart mail, this represent 'epilogue' string. Else, void string.
date( default = nil )
date=( time )
time in 'Date' header field
strftime( format )
is equals to tmail.date.strftime(format). If date is not exist this method does nothing and returns nil.
to( default = nil ) : String
to=( str )
the first 'To' address
to_addrs( default = nil ) : Array of Address
to_addrs=( array : Array of Address )
Addresses represented in To: header. The return value is an Array of Address objects.
from( default = nil ) : String
from=( str )
the first 'From' address
from_addrs( default = nil ) : Array of Address
'From' addresses.
subject( default = nil ) : String
subject=( str )
mail subject.
reply_to_addrs( default = nil ) : Array of Address
'Reply-To' addresses.
sender( default = nil ) : Address
sender=( str )
'Sender' address.
message_id( default = nil )
message_id=( str )
'Message-Id' string
in_reply_to( default = nil ) Array of String
in_reply_to=( arr )
'In-Reply-To' message IDs.
references( default = nil )
references=( arr : Array of String )
'References' message IDs.
mime_version( default = nil ) : String
mime_version=( str )
mime_version=( major, minor )
MIME version. Currently only '1.0' is defined.
main_type( default = nil )
main content-type.
sub_type( default = nil )
sub content-type.
charset( default = nil ), charset=( str )
charset parameter in content-type header.
set_content_type( main: String, sub: String, param: Hash = nil )
set 'Content-type' header as "main/sub; param=val; param=val; ...".
multipart?
True if it is MIME multipart mail.
encoding( default = nil ) : String
encoding=( str : String )
'Content-Transfer-Encoding'. Normally '7bit', 'Base64', '8bit... are used.
disposition( default = nil ) : String
disposition=( str )
'Content-Disposition' main value. e.g. "attach"
set_content_disposition( dispos, params = nil )
set content disposition. PARAMS is a Hash like {"name"=>"value"}.
destinations( default = nil ) : Array of String
all the addresses in 'To', 'Cc', 'Bcc'.
each_dest {|addr| ....}
iterate for each destination. ADDR is an address, typed String.
reply_addresses( default = nil ) : Array of Address
the addresses to use when replying.
error_reply_addresses( default = nil )
the addresses to use when returning error message.
clear
clears all header.
each_key {|header_name| .....}
iterates for each header name.
keys
returns an array of included headers' name.
self[ key ]
returns a header field object corresponding to the case-insensitive header name. e.g. mail[ 'To' ]
self[ key ] = val
sets the header corresponding to the case-insensitive header name.
delete( key )
delete 'key' header.
delete_if {|key, val| .... }
This method evaluates block with a name of header and header field object, and if true delete the header.
each {|key, val| .... }
each_pair {|key, val| .... }
iteration for each header name and its field object.
each_value {|val| .... }
iteration for each header field object.
self[ key ]
fetch( key, default_body = nil )
fetch( key ) { .... }
return header field object for 'key' header. Some header returns an array of header field object (ex: Received).

In case there's no 'key' header, execute "add_header(key,default_body)" and return its header object. In case 'default_body' is nil and also there's no block was given use its return value as 'default_body'.

has_key?( key )
include?( key )
key?( key )
true if the mail has 'key' header
has_value?( val )
value?( val )
If the mail has 'val' header field object, return true.
indexes( *keys )
indices( *keys )
same to "keys.collect {|k| tmail[k] }"
store( key, val )
set a header object as content of 'key' header. "val" must be a HeaderField or String.
values
an array of all header field object.

Copyright (c) 1998-2001 Minero Aoki <aamine@loveruby.net>