class TMail::Mail new( port: TMail::Port = TMail::StringPort.new, config: TMail::Config = DEFAULT_CONFIG ) -> TMail::Mail
creates a new TMail::Mail object from port.
load( filename: String ) -> TMail::Mail
creates a new TMail::Mail object. filename is the name of file
which contains just one mail (e.g. MH mail file).
parse( str: String ) -> TMail::Mail
parses str and creates a new TMail::Mail object.
port -> TMail::Portthe source port of this mail.
body_port -> TMail::Portthe port to save body of this mail.
each {|line| .... }iterates for each lines of mail body.
body -> Stringpreamble -> Stringthe mail body. If the mail is a MIME multipart mail, this attribute represents "preamble".
parts -> Array of TMail::Mailparts of this mail. (valid only if this mail is a MIME multipart mail)
epilogue -> StringIf the mail was MIME multipart mail, this represent "epilogue" string. Else, empty string.
multipart?true if the message is a multi-part mail.
encoded( eol = "\n", encoding = 'j' ) -> Stringconverts the mail object to a MIME encoded string.
decoded( eol = "\n", encoding = 'e' ) -> Stringto_s( eol = "\n", encoding = 'e' ) -> Stringconverts the mail object to a decoded string.
inspect -> String
returns simple string representation like
"#<TMail::Mail port=<StringPort:str=...>>"
write_back( eol = "\n", encoding = 'e' )
converts this mail into string and write back to body_port,
setting line terminator to eol.
date( default = nil ) -> Timea time object of Date: header field.
strftime( format: String, default = nil ) -> String
is equals to date.strftime(format).
If date is not exist, this method does nothing and
returns default.
to( default = nil ) -> Array of Stringto=( addrs: String/Array of String )address specs for To: header field.
to_addrs( default = nil ) -> Array of TMail::Addressto_addrs=( addrs: TMail::Address/Array of TMail::Address )adresses which is represented in To: header field.
cc( default = nil ) -> Array of Stringcc=( addrs: String/Array of String )address specs for Cc: header field.
cc_addrs( default = nil ) -> Array of TMail::Addresscc_addrs=( addrs: TMail::Address/Array of TMail::Address )addresses which is represented in Cc: header field.
bcc( default = nil ) -> Array of Stringbcc=( addrs: String/Array of String )address specs for Bcc: header field.
bcc_addrs( default = nil ) -> Array of TMail::Addressbcc_addrs=( addrs: TMail::Address/Array of TMail::Address )adresses which is represented in Bcc: header field.
from( default = nil ) -> Array of Stringfrom=( addrs: String/Array of String )address specs for From: header field.
from_addrs( default = nil ) -> Array of TMail::Addressfrom_addrs=( addrs: TMail::Address/Array of TMail::Address )adresses which is represented in From: header field.
friendly_from( default = nil ) -> Stringa "phrase" part or address spec of the first From: address.
reply_to( default = nil ) -> Array of Stringreply_to=( addrs: String/Array of String )address specs of Reply-To: header field.
reply_to_addrs( default = nil ) -> Array of TMail::Addressreply_to_addrs=( addrs: TMail::Address/Array of TMail::Address )adresses which is represented in Reply-To: header field.
sender( default = nil ) -> Stringsender=( addr: String )address spec for Sender: header field.
sender_addr( default = nil ) -> TMail::Addresssender_addr=( addr: TMail::Address )an address which is represented in Sender: header field.
subject( default = nil ) -> Stringsubject=( sbj: String )the subject of the message.
message_id( default = nil ) -> Stringmessage_id=( id: String )message id string.
in_reply_to( default = nil ) -> Array of Stringin_reply_to=( ids: String/Array of String )message IDs of replying mails.
references( default = nil ) -> Array of Stringreferences=( ids: String/Array of String )message IDs of all referencing (replying) mails.
mime_version( default = nil ) -> Stringmime_version=( ver: String )MIME version. If it does not exist, returns the DEFAULT.
set_mime_version( major: Integer, minor: Integer )set MIME version from integers.
content_type( default = nil ) -> Stringthe content type of the mail message (e.g. "text/plain"). If it does not exist, returns the default.
main_type( default = nil ) -> Stringthe main content type of the mail message. (e.g. "text") If it does not exist, returns the default.
sub_type( default = nil ) -> Stringthe sub content type of the mail message. (e.g. "plain") If it does not exist, returns the default.
content_type=( main_sub: String )set content type to STR.
set_content_type( main: String, sub: String, params: Hash = nil )set Content-type: header as "main/sub; param=val; param=val; ...".
type_param( name: String, default = nil ) -> Stringreturns the value corresponding to the case-insensitive name of Content-Type parameter. If it does not exist, returns the default.
# example mail['Content-Type'] = 'text/plain; charset=iso-2022-jp' p mail.type_param('charset') # "iso-2022-jp"
multipart? -> booljudge if this mail is MIME multi part mail, by inspecting Content-Type: header field.
transfer_encoding( default = nil ) -> Stringtransfer_encoding=( str: String )Content-Transfer-Encoding. (e.g. "7bit" "Base64")
disposition( default = nil ) -> StringContent-Disposition main value (e.g. "attach"). If it does not exist, returns the default.
# example mail['Content-Disposition'] = 'attachement; filename="test.rb"' p mail.disposition # "attachment"
set_content_disposition( pos: String, params: Hash = nil )set content disposition. params is a Hash, like {"name"=>"value"}.
disposition_param( name: String, default = nil ) -> Stringreturns a value corresponding to the Content-Disposition parameter name (e.g. filename). If it does not exist, returns the default.
# example mail.disposition_param('filename')
destinations( default = nil ) -> Array of Stringall address specs which are contained in To:, Cc: and Bcc: header fields.
reply_addresses( default = nil ) -> Array of TMail::Addressaddresses to we reply to.
error_reply_addresses( default = nil ) -> Array of TMail::Addressaddresses to use when returning error message.
clearclears all header.
keys -> Array of TMail::HeaderFieldreturns an array of contained header names.
[]( name ) -> TMail::HeaderFieldreturns a header field object corresponding to the case-insensitive key name. e.g. mail["To"]
[]=( name, field )set name header field to field.
delete( key )deletes header corresponding to case-insensitive key key.
delete_if {|key, val| .... }evaluates block with a name of header and header field object, and delete the header if block returns true.
each_header {|name, field| .... }each_pair {|name, field| .... }iterates for each header name and its field object.
each_header_name {|name| .... }each_key {|name| .... }iterates for each contained header names.
each_field {|field| .... }each_value {|field| .... }iterates for each header field objects.
orderd_each {|name, field| .... }iterates for each header field objects, in canonical order.
key?( name )returns true if the mail has name header.
value?( field )returns true if the mail has field header field object.
values_at( *keys ) -> Array of TMail::HeaderFieldindexes( *keys ) -> Array of TMail::HeaderFieldindices( *keys ) -> Array of TMail::HeaderField
equals to keys.collect {|k| mail[k] }.
values -> Array of TMail::HeaderFieldreturns an array of all header field object.