我的目标是能够通过linux服务器从gmail帐户中读取新消息。我想我可以通过IMAP或其他方式来实现,但我希望尽可能避免这种复杂性因为gmail有这个很好的提要设置:
https://mail.google.com/mail/feed/atom/唯一的问题是,我不确定如何验证调用拉这个。这可能吗?
一个好的起点应该是:
curl -u username:password --silent "https://mail.google.com/mail/feed/atom" | tr -d 'n' | awk -F '<entry>' '{for (i=2; i<=NF; i++) {print $i}}' | sed -n "s/<title>(.*)</title.*name>(.*)</name>.*/2 - 1/p"
为您的帐户检查Gmail ATOM提要,对其进行解析并输出未读消息列表。
还有,看这个线程:http://www.commandlinefu.com/commands/view/3380/check-your-unread-gmail-from-the-command-line
OTOH,我建议使用mutt
和IMAP。