有没有办法只提取从 Gmail 收到的电子邮件
我正在尝试使用 IMAP 从 gmail(好吧,Google Apps 邮件,但足够接近)中提取传入的电子邮件。我想要所有好的邮件(不是垃圾邮件/已删除的邮件),即使它们已归档到不同的文件夹中(因此通过收件箱运行是不够的),但我不希望从当前帐户或草稿(两者都)发送邮件显示在“所有邮件”文件夹中)。
这是为了广泛使用,所以我不能假设除了收件箱之外只有某些特定的已知文件夹名称需要检查。
I'm trying to extract incoming emails from gmail (well, Google Apps mail, but near enough) using IMAP. I want all good messages (not spam/deleted) even if they have been filed in different folders (so running through the Inbox is not sufficient), but I don't want messages sent from the current account, or drafts (both of which show up in the 'All Mail' folder).
This is for widespread use, so I can't just assume that there's only certain specific known folder names in addition to the Inbox to check.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
更新
不,这实际上不能正常工作。使用其他域没有
[$]NOTJUNK
标志;我的猜测是这些是由 Apple Mail 设置的。/UPDATE
到目前为止,我设法获得的最佳结果是在 AllMail 文件夹中找到设置了
$NOTJUNK
标志的邮件,但NOTJUNK
(无 $)标志未设置,并过滤掉从 Sent 文件夹返回的邮件。根据我所做的简短测试,
NOTJUNK
仅针对草稿邮件设置(例如来自 Apple Mail,但不适用于 Web 界面内的草稿 - 在这种情况下,NOTJUNK
都不是)也没有设置 $NOTJUNK)注意:我使用
xlist
来查找这些文件夹的正确本地化版本。UPDATE
Nope, this doesn't actually work properly. Working with another domain doesn't have the
[$]NOTJUNK
flags; my guess is that these are set by Apple Mail./UPDATE
The best result I've managed to get so far is to find the messages in the AllMail folder with the
$NOTJUNK
flag set, but theNOTJUNK
(no $) flag unset and filter out the messages that are returned from the Sent folder.From the brief testing I've done
NOTJUNK
was only set for draft messages (eg from Apple Mail, but not for drafts from within the web interface - in that case neitherNOTJUNK
nor$NOTJUNK
were set)Note: I'm using
xlist
to find the correct localised versions of these folders.由于
NOTJUNK
标志似乎不可靠,我现在从 AllMail 文件夹中获取所有邮件,丢弃来自 Sent 文件夹中的邮件,然后然后丢弃那些没有具有Delivered-To
标头的草稿(我希望草稿是唯一没有此标头的草稿)Since the
NOTJUNK
flags seem unreliable, I'm now getting all messages from the AllMail folder, throwing away the ones from the Sent folder, and then throwing away the ones that don't have theDelivered-To
header (I hope the drafts are the only ones without this header)