Reading email from the mail gem

Here's how to read email from the 'mail' gem:

require 'mail'

Mail.defaults do
  retriever_method :pop3, { :address             => "localhost",
                           :port                => 110,
                           :user_name           => 'admin',
                           :password            => 'secret',
                           :enable_ssl          => false }

email = Mail.all
email.length #=> 2

mail = email[0]
mail.envelope.from   #=> ''
mail.from.addresses  #=> ['', '']
mail.sender.address  #=> ''              #=> ''              #=> ''
mail.subject         #=> "This is the subject"       #=> '21 Nov 1997 09:55:06 -0600'
mail.message_id      #=> '<>'
mail.body.decoded    #=> 'This is the body of the email...

Here's all the public me thods for mail (- Object.public_methods):

[]                     []=                     action
add_charset            add_content_transfer_encoding add_content_type
add_date               add_file                add_message_id
add_mime_version       add_part                add_transfer_encoding
all_parts              atom_safe?              attachment
attachment?            attachments             bcc
bcc=                   bcc_addrs               body
body=                  body_encoding           body_encoding=
bounced?               boundary                bracket
capitalize_field       cc                      cc=
cc_addrs               charset                 charset=
comments               comments=               constantize
content_description    content_description=    content_disposition
content_disposition=   content_id              content_id=
content_location       content_location=       content_transfer_encoding
content_transfer_encoding= content_type            content_type=
content_type_parameters convert_to_multipart    dasherize
date                   date=                   decode_body
decoded                default                 deliver
deliver!               delivery_handler        delivery_handler=
delivery_method        delivery_status_part    delivery_status_report?
destinations           diagnostic_code         dquote
encode!                encoded                 envelope_date
envelope_from          error_status            errors
escape_paren           filename                final_recipient
find_first_mime_type   from                    from=
from_addrs             has_attachments?        has_charset?
has_content_transfer_encoding? has_content_type?       has_date?
has_message_id?        has_mime_version?       has_transfer_encoding?
header                 header=                 header_fields
headers                html_part               html_part=
in_reply_to            in_reply_to=            inform_interceptors
inform_observers       is_marked_for_delete?   keywords
keywords=              main_type               map_lines
map_with_index         mark_for_delete=        match_to_s
message_content_type   message_id              message_id=
method_missing         mime_parameters         mime_type
mime_version           mime_version=           multipart?
multipart_report?      paren                   part
parts                  perform_deliveries      perform_deliveries=
quote_atom             quote_phrase            quote_token
raise_delivery_errors  raise_delivery_errors=  raw_envelope
raw_source             read                    ready_to_send!
received               received=               references
references=            register_for_delivery_notification remote_mta
reply                  reply_to                reply_to=
resent_bcc             resent_bcc=             resent_cc
resent_cc=             resent_date             resent_date=
resent_from            resent_from=            resent_message_id
resent_message_id=     resent_sender           resent_sender=
resent_to              resent_to=              retryable?
return_path            return_path=            sender
sender=                set_envelope            skip_deletion
sub_type               subject                 subject=
text?                  text_part               text_part=
to                     to=                     to_addrs
token_safe?            transfer_encoding       transport_encoding
transport_encoding=    unbracket               underscoreize
unparen                unquote                 uri_escape
uri_parser             uri_unescape            without_attachments!


10-08-2012 22:23