Last active
December 14, 2015 20:59
-
-
Save wobh/5147510 to your computer and use it in GitHub Desktop.
Basic usage of Ruby mail.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # https://github.com/mikel/mail | |
| # http://rdoc.info/github/mikel/mail/Mail | |
| #### Retrieving mail | |
| yahoo_imap = { | |
| :address => "imap.mail.yahoo.com", | |
| :port => 993, | |
| :user_name => "", | |
| :password => "", | |
| :enable_ssl => true | |
| } | |
| # http://help.yahoo.com/kb/index?page=content&id=SLN3773 | |
| google_imap = { | |
| :address => "imap.gmail.com", | |
| :port => 993, | |
| :user_name => "", | |
| :password => "", | |
| :enable_ssl => true | |
| } | |
| # http://support.google.com/mail/troubleshooter/1668960?hl=en&rd=1 | |
| Mail.defaults { retriever_method :imap, imap } | |
| # http://rdoc.info/github/mikel/mail/Mail/Retriever | |
| # Mail.all | |
| # Mail.first | |
| # Mail.last | |
| #### Parse email messages | |
| mail = Mail.read('/path/to/message.eml') | |
| mail.to | |
| # "mail.to" should return group email address, | |
| # "[email protected]" | |
| mail.date | |
| mail.subject | |
| mail.message_id | |
| mail['X-Yahoo-Group-Post'] | |
| # Questions | |
| # How to save retrieved emails to offline mailbox? | |
| # How to interact and manage with offline mailbox? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment