jhk753 / gmail-ruby-api

Ruby interface for Gmail API
Other
26 stars 20 forks source link

Is there a good way of getting the from address from a received mail? #13

Closed Carpela closed 9 years ago

Carpela commented 9 years ago

Can get from in the gmail syntax i.e. "Bob Smith bob@smith.com" Is there a way of getting just the address as per

mail.to
"Bob Smith <bob@smith.com>"
mail.delivered_to
"bob@smith.com"
mail.from
"John Smith <john@smith.com>"
mail.?????
"john@smith.com"
jhk753 commented 9 years ago

Unfortunately the Gmail API doesn't parse headers way more than what Google gives us.

If you want to add extra methods to Message Object. I feel that this gem should keep on basic parsing. Parsing mail.from and getting just the name of just the email is something that you can do very easily on your end.

For example: mail.from[/<(.*?)>/m, 1] will return "john@smith.com" in your example