How can I get a list of all messages in my gmail account in linux command line?

3

1

How can I get a list of all messages in my gmail account in linux command line? Ideally I would want to see something similar to:

from:sender1@domain.com to:me@gmail.com Date:11/22/33 subj:Foo1
from:sender2@domain.com to:me@gmail.com Date:11/22/33 subj:Foo2

Not necessary with words from, to etc or certain order. Thank you

GoodbyeDropbox

Posted 2014-03-09T15:27:27.637

Reputation: 31

I'm guessing you want this to be a done repeatedly? Sort of like an update? – Reuben L. – 2014-03-09T15:33:23.050

Most likely solution would entail:

(1) Use of a commandline browser like lynx

(2) Either a post command or Gmail API (if you use the email with Google Apps)

(3) The use of the html-based UI page for your inbox: http://mail.google.com/mail/?ui=html with a parameter like -dump in lynx to move it to stdout. – Reuben L. – 2014-03-09T15:43:29.507

Answers

1

You can combine the Gmail API with a shell script found here.

This will write to the screen if you have email or not.

Just change the USERNAME & PASSWORD entries to your own.

#!/bin/bash
## Quickly checks if I have new gmail

echo -e "Checking for new messages... \c"

atomlines=`wget -T 3 -t 1 -q --secure-protocol=TLSv1 \
 --no-check-certificate \
 --user=USERNAME --password=PASSWORD \
 https://mail.google.com/mail/feed/atom -O - \
 | wc -l`

echo -e "\r\c"

[ $atomlines -gt "8" ] \
 && echo -e " You have new gmail.  \c" \
 || echo -e " No new gmail.  \c"

dkanejs

Posted 2014-03-09T15:27:27.637

Reputation: 675