I'm on Ubuntu and I have some email accounts on gmail that I would like to poll every once in awhile to see if there's any new mail. I want to write a script for this, so that everytime I run the script it tells me how many new messages I have from my account(s). What application would I have to run from the command line to do such a thing? Everything I find online talks about using the "mail" command, but that seems to check some local mail directory instead of my remote email (obviously, any such application would also require me to configure it to log into my account with the correct password).
Try the following:
curl -u [email protected]:password --silent "https://mail.google.com/mail/feed/atom" | perl -ne 'print "\t" if /<name>/; print "$2\n" if /<(title|name)>(.*)<\/\1>/;' | espeak
Python makes it fairly easy to check IMAP accounts without needing to install any extra packages.
There's a good writeup at Yuji Tomita's blog on how to use python's imaplib to talk to Gmail. http://yuji.wordpress.com/2011/06/22/python-imaplib-imap-example-with-gmail/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With