Check Gmail From the Command Line

Gmail provides the ability to view your new/unread email as an ATOM feed via https://mail.google.com/mail/feed/atom.  With cURL and some Perl we can check gmail from the Linux command line.

Just change the email address to your email address and when your hit enter you will be prompted for your gmail password.

#!/bin/bash
curl -u motersho@gmail.com --silent "https://mail.google.com/mail/feed/atom" |
 perl -ne \
  '
    print "SUBJECT: $1 \n" if /<title>(.+?)<\/title>/;
    print "RECEIVED $1 \n" if /<issued>(.+?)<\/issued>/;
    print "FROM: $1 " if /<name>(.+?)<\/name>/;
    print "($1)\n\n" if /<email>(.+?)<\/email>/;
  '
This entry was posted in Bash Scripts, Linux, Programming. Bookmark the permalink.

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">