1
# The Mail class represents an internet mail message (as per RFC822, RFC2822)
2
# with headers and a body.
5
# Create a new Mail where +f+ is either a stream which responds to gets(),
6
# or a path to a file. If +f+ is a path it will be opened.
8
# The whole message is read so it can be made available through the #header,
9
# #[] and #body methods.
11
# The "From " line is ignored if the mail is in mbox format.
13
unless defined? f.gets
23
next if /^From /=~line # skip From-line
24
break if /^$/=~line # end of header
26
if /^(\S+?):\s*(.*)/=~line
27
(attr = $1).capitalize!
31
@header[attr] += "\n" + line
38
break if /^From /=~line
46
# Return the headers as a Hash.
51
# Return the message body as an Array of lines
56
# Return the header corresponding to +field+.
58
# Matching is case-insensitive.
60
@header[field.capitalize]