Created
August 2, 2011 02:02
-
-
Save kshep/1119441 to your computer and use it in GitHub Desktop.
Ruby script to pull all "From:" addresses from every message in your "All Mail" Gmail folder
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
#!/usr/bin/env ruby | |
require 'net/imap' | |
imap = Net::IMAP.new('imap.gmail.com',993,true) | |
imap.login('USERNAME', 'PASSWORD') | |
imap.select('[Gmail]/All Mail') | |
imap.search(['ALL']).each do |message_id| | |
msg = imap.fetch(message_id,'ENVELOPE')[0].attr['ENVELOPE'] | |
from = msg.from[0] | |
if from.name | |
puts "'#{from.name}' <#{from.mailbox}@#{from.host}>" | |
else | |
puts "#{from.mailbox}@#{from.host}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment