Hash of Mail headers

I’m using the mail API as so:

require ‘yaml’
require ‘net/imap’
require ‘mail’

yaml = File.open( “/home/thufir/ruby/email.yml” )
email = YAML.load_file( yaml )

server = email[“server”]
user = email[“user”]
password = email[“password”]

puts server
puts user
puts password

imap = Net::IMAP.new(server)
puts “connected”
imap.login(user,password)
puts “logged in”
imap.select(‘INBOX’)
mailIds = imap.search([‘ALL’])
mailIds.each do |id|
puts ‘ok’
msg = imap.fetch(id,‘RFC822’)[0].attr[‘RFC822’]
mail = Mail.new(msg)
subj = mail.subject # HERE’S THE SUBJECT FROM THE HEADER
puts subj
end
imap.logout()
imap.disconnect()

and have no problem getting the subject header, that’s all good. How do
I get the other headers? Or a Hash of headers? Non-standard headers.

thanks,

Thufir

On Sat, Dec 15, 2012 at 3:14 AM, Thufir [email protected] wrote:

I’m using the mail API as so:

and have no problem getting the subject header, that’s all good. How do I
get the other headers? Or a Hash of headers? Non-standard headers.

Have you looked at the doc? There’s an object called Mail::Header :slight_smile: