Skip to content

Instantly share code, notes, and snippets.

@saramic
Created February 5, 2013 23:29
Show Gist options
  • Save saramic/4718702 to your computer and use it in GitHub Desktop.
Save saramic/4718702 to your computer and use it in GitHub Desktop.
from the command line get the lastest 10 emails from GMail and print the from email address. assumes ruby and rubygems are installed.
# based on http://dcparker.github.com/ruby-gmail/
# get latest 10 email addresses from GMail inbox emails
gem install gmail
export USRENAME=my_name PASSWORD=my_password
ruby -e 'require "rubygems"; require "gmail"; \
Gmail.new(ENV["USERNAME"], ENV["PASSWORD"]){|gmail| \
gmail.inbox.emails.each_with_index{|email, index| \
puts email.from.collect{|address| \
"#{address.mailbox}@#{address.host}"}; break if index > 9 } }'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment