Accessing TMail::Mail headers
While trying to test TMail::Mail#to header, despite setting the address in full with the recipients name I kept getting just the address back
>> t = TMail::Mail.new
=> #<TMail::Mail port=#<TMail::StringPort:id=0x3ff92369be30> bodyport=nil>
>> t.to = "RobL <someaddress@robl.me>"
=> "RobL <someaddress@robl.me>"
>> t.to
=> ["someaddress@robl.me"]
It seems there are a few ways of grabbing the to address back, to just returns an array of e-mail addresses. to_addrs or [‘to’] actually return the full “to” address.
>> t.to_addrs
=> [#<TMail::Address contact@robl.me>
>> t.to_addrs.first.to_s
=> "RobL <someaddress@robl.me>"
>> t['to'].first.to_s
=> "RobL <someaddress@robl.me>"