Sorry to dig up this old thread, but I just came across this and thought it was a great idea. I had trouble getting this script to work for a domain account though, so I figured I'd share the updated script in case anyone else was trying to do the same thing.
The user/password had to be pulled out of the URL. Since they contained '@', they were confusing wget. Use the following instead. Note: be sure to surround your username/password in quotes.
Code:
un="user@domain.com"
pw="password"
mails="$(wget --secure-protocol=TLSv1 --http-user=${un} --http-password=${pw} \
--timeout=3 -t 1 -q -O - \
https://mail.google.com/mail/feed/atom \
--no-check-certificate | grep 'fullcount' \
| sed -e 's/.*<fullcount>//;s/<\/fullcount>.*//' 2>/dev/null)"
<insert chosen flavor of alerting of emails>
Also, I've found that the mail/feed/atom/important tag always returns a fullcount of 0, even with unread messages. I'm not sure why this is, but it's annoying. Anyone have ideas about it?
Bookmarks