# TMail::Mail class

## Super Class

Object

## Class Methods

`new( arg )` : TMail
  This method creates new TMail object.
  "arg" is an instance of Port.
`loadfrom( filename )` : TMail
  This method creates a TMail object. "filename" is name of file which contain only one mail (e.g. Mh mail file).
`boundary`
  return new "boundary" at random.
`msgid`
  return new "message ID". If TMail can get host name, string is "", else ""
  I do not recommend to use this method.

## Method

to( default = '' ) : String
  return the first 'To' address. If there's no 'To' header, return arg 'default'.
to=( str: String )
  set 'str' as 'To' header
from( default = '' ): String
  return the first 'From' address. If there's no 'From' header, return arg 'default'.
from_phrase( default = '' ): String
  return a phrase of the first 'From' address. If there's no 'From' header, return arg 'default'.
from=( str: String )
  set 'str' for 'From' header
subject( default = '' ): String
  return body of 'Subject'. If there's no 'Subject' header, return arg 'default'.
subject=( str: String )
  set 'str' for 'Subject'.
msgid( default = '' ): String
  return 'Message-ID'. If there's no 'Message-ID' header, return arg 'default'.
msgid=( str: String )
  set 'str' for Message-ID.
maintype( default = nil )
  return main content-type.
subtype( default = nil )
  return sub content-type.
charset( default = nil )
  return charset parameter in content-type header.
charset=( str: String )
  set 'str' for charset.
set_contenttype( main: String, sub: String, param: Hash = nil )
  set 'Content-type' header as "main/sub; param=val; param=val; ...".
encoding( default = nil ): String
  return the body of 'Content-Transfer-Encoding'.
encoding=( str: String )
  set 'str' for 'Content-Transfer-Encoding'.
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: String )
  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

  iteration for each header name and its field object.
each_value{|val| .....}
  iteration for each header field object.

- fetch( key: String, default_body: String ) : HeaderField
- fetch( key: String ){ ..... } : HeaderField

  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: String ): Boolean
- include?( key: String ): Boolean
- key?( key: String ): Boolean

  If the mail has 'key' header, return true.

- has_value?( val: HeaderField ): Boolean
- value?( val: HeaderField ): Boolean

  If the mail has 'val' header field object, return true.

- indexes( *keys ): Array of HeaderField
- indices( *keys ): Array of HeaderField

  return "keys.collect{|i| fetch(i)}"
store( key: String, val: HeaderField )
  This method set a header object as content of 'key' header.
values
  returns an array of all header field object.

- `body` : String
- `preamble` : String

  return mail body. If the mail was MIME multipart mail, this represent 'preamble'.
`parts`: Array of TMail``
  If the mail was MIME multipart mail, each element represents MIME part. If not, this is void array.
`epilogue`: String``
  If the mail was MIME multipart mail, this represent 'epilogue'. Else, void string.
`multipart?```
  True if it is MIME multipart mail.
`to_s( eol = "\n", header_sep = '' )`
  convert it to a string.
  If there's ESC in header, TMail encode the header (only 'B' encode can be used).

  'header_sep' is separator of header and body. ex: '----' for Mh mail.

`inspect( eol = "\n", header_sep = '' )`
  convert it to a string. This method is equal to 'to_s' except 'inspect' does not encode header.

  Copyright (c) 1999,2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>