Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check for new email using command line

Tags:

linux

email

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).

like image 533
bhh1988 Avatar asked Jun 29 '26 00:06

bhh1988


2 Answers

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
like image 172
user2043985 Avatar answered Jul 01 '26 19:07

user2043985


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/

like image 21
Sam Mussmann Avatar answered Jul 01 '26 20:07

Sam Mussmann