Created
November 27, 2010 19:31
-
-
Save coreyward/718195 to your computer and use it in GitHub Desktop.
Fetch emails from a Gmail account via IMAP for processing
This file contains 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
# Via http://blog.ethanvizitei.com/2008/06/using-ruby-for-imap-with-gmail.html | |
imap = Net::IMAP.new(@config['server'],@config['port'],true) | |
imap.login(@config['username'], @config['password']) | |
imap.select('INBOX') | |
imap.search(["NOT", "DELETED"]).each do |message_id| | |
MailFetcher.receive(imap.fetch(message_id, "RFC822")[0].attr["RFC822"]) | |
imap.store(message_id, "+FLAGS", [:Deleted]) | |
end | |
imap.logout() | |
imap.disconnect() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment