Wednesday, December 3, 2008

Get GMail using Curl

Easily check for the availability of new e-mail messages on gmail using curl, the Linux web utility.
This method will give you the total number of new messages in your inbox.

curl -u USERNAME:PASSWORD -s https://mail.google.com/mail/feed/atom/inbox | grep -e '<fullcount>' | sed -e 's/<[^>]*>//g' | awk '{print "\nNew G-Mail Messages: " $1}'

You can alter this command to show you how many new messages are new under a different label such as unread by changing the url to the label you want to access, for instance: https://mail.google.com/mail/feed/atom/unread