# TMail::Mail class

## Module Methods

`new_boundary`
  return new "boundary" at random.
`new_msgid`
  return new "message ID". If TMail can get host name, string is "", else ""
  I do not recommend to use this method.
`quote( str )`
  quote string if it is not mail-safe
`quote_phrase( str )`
  quote string if it is not mail-safe (for phrase; allow spaces)

# 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.
`parse( str )` : TMail::Mail
  parse string STR and creates a new TMail::Mail 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).

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

`date( default = nil ), date=( time )`
  time in 'Date' header field
to( default = nil ), to=( str )
  the first 'To' address
from( default = nil ), from=( str )
  the first 'From' address
from_phrase( default = nil ): String
  return a phrase of the first 'From' address. If there's no 'From' header, return arg 'default'.
subject( default = nil ), subject=( str )
  body of 'Subject'
msgid( default = nil ), msgid=( str )n
  'Message-Id' string
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; ...".
encoding( default = nil ), encoding=( str )
  the body of 'Content-Transfer-Encoding'.
destinations
  all the addresses in 'To', 'Cc', 'Bcc'. return value is Array of String.
each_dest {|addr| ....}
  iterate for each destination. 'addr' is address (format is "...@...")
clear
  clear all header.
each_key {|header_name| .....}
  iterate for each header name.
keys
  return an array of header name.
self[ key ]
  return a header field object by header name. ex: tmail[ 'To' ]
self[ key ] = val
  This method set a header object as a content of 'key' header.
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.
`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.
`multipart?```
  True if it is MIME multipart mail.

Copyright (c) 1998-2001 Minero Aoki <aamine@dp.u-netsurf.ne.jp>