获取邮件未读内容,不影响未读状态

发布于 2024-08-08 04:13:12 字数 218 浏览 3 评论 0原文

现在它是一个 Gmail 邮箱,但迟早我希望它能够扩展。

我想在其他地方同步实时个人邮箱(收件箱和发件箱)的副本,但我不想影响任何未读邮件的未读状态。

什么类型的访问将使这变得最简单?我找不到 IMAP 是否会影响阅读状态的任何信息,但看来我可以手动将邮件重置为未读。根据定义,Pop 不会影响未读状态,但似乎没有人使用 Pop 来访问他们的 Gmail,为什么?

Right now its a gmail box but sooner or later I want it to scale.

I want to sync a copy of a live personal mailbox (inbox and outbox) somewhere else, but I don't want to affect the unread state of any unread messages.

what type of access will make this easiest? I can't find any information if IMAP will affect the read state, but it appears I can manually reset a message to unread. Pop by definition doesn't affect unread state but nobody seems to use pop to access their gmail, why?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

唯憾梦倾城 2024-08-15 04:13:13

if it helps anyone, GAE allows you to receive email as an HTTP request, so for now i'm just forwarding emails there.

秋意浓 2024-08-15 04:13:13

跟进上面 Dan Goldstein 的回答 ,在 python 中使用“.PEEK”选项的语法是调用 IMAP4.fetch 并传递它“BODY.PEEK< /a>"

将此应用于 python 文档 中的示例:

import getpass, imaplib

M = imaplib.IMAP4()
M.login(getpass.getuser(), getpass.getpass())
M.select()
typ, data = M.search(None, 'ALL')
for num in data[0].split():
    typ, data = M.fetch(num, '(BODY.PEEK)')
    print 'Message %s\n%s\n' % (num, data[0][5])
M.close()
M.logout()

To follow up on Dan Goldstein's answer above, in python the syntax to use the ".PEEK" option would be to call IMAP4.fetch and pass it "BODY.PEEK"

To apply this to the example in the python docs :

import getpass, imaplib

M = imaplib.IMAP4()
M.login(getpass.getuser(), getpass.getpass())
M.select()
typ, data = M.search(None, 'ALL')
for num in data[0].split():
    typ, data = M.fetch(num, '(BODY.PEEK)')
    print 'Message %s\n%s\n' % (num, data[0][5])
M.close()
M.logout()
很快妥协 2024-08-15 04:13:12

在 IMAP 世界中,每条消息都有标志。您可以在每条消息上设置单独的标志。当您获取消息时,实际上可以在不应用 \Seen 标志的情况下读取该消息。

大多数邮件客户端在阅读邮件时都会应用 \Seen 标志。因此,如果该消息已在您的应用程序之外被阅读,那么您将需要删除 \Seen 标志。

正如仅供参考...这里是有关 RFC 中标志的相关部分:

系统标志是在此预定义的标志名称
规格。所有系统标志均以“\”开头。某些系统
标志(\Deleted 和 \Seen)具有特殊的语义描述
别处。当前定义的系统标志是:

    \Seen
       Message has been read

    \Answered
       Message has been answered

    \Flagged
       Message is "flagged" for urgent/special attention

    \Deleted
       Message is "deleted" for removal by later EXPUNGE

    \Draft
       Message has not completed composition (marked as a draft).

    \Recent
       Message is "recently" arrived in this mailbox.  This session
       is the first session to have been notified about this
       message; if the session is read-write, subsequent sessions
       will not see \Recent set for this message.  This flag can not
       be altered by the client.

       If it is not possible to determine whether or not this
       session is the first session to be notified about a message,
       then that message SHOULD be considered recent.

       If multiple connections have the same mailbox selected
       simultaneously, it is undefined which of these connections
       will see newly-arrived messages with \Recent set and which
       will see it without \Recent set.

In the IMAP world, each message has flags. You can set the individual flags on each message. When you Fetch a message, it's actually possible to read the message, without applying the \Seen flag.

Most mail clients will apply the \Seen flag when the message is read. So, if the message has already been read, outside of your app, then you will need to remove the \Seen flag.

Just as fyi...here is the relevant part about flags from the RFCs:

A system flag is a flag name that is pre-defined in this
specification. All system flags begin with "\". Certain system
flags (\Deleted and \Seen) have special semantics described
elsewhere. The currently-defined system flags are:

    \Seen
       Message has been read

    \Answered
       Message has been answered

    \Flagged
       Message is "flagged" for urgent/special attention

    \Deleted
       Message is "deleted" for removal by later EXPUNGE

    \Draft
       Message has not completed composition (marked as a draft).

    \Recent
       Message is "recently" arrived in this mailbox.  This session
       is the first session to have been notified about this
       message; if the session is read-write, subsequent sessions
       will not see \Recent set for this message.  This flag can not
       be altered by the client.

       If it is not possible to determine whether or not this
       session is the first session to be notified about a message,
       then that message SHOULD be considered recent.

       If multiple connections have the same mailbox selected
       simultaneously, it is undefined which of these connections
       will see newly-arrived messages with \Recent set and which
       will see it without \Recent set.
行雁书 2024-08-15 04:13:12

IMAP 中的 FETCH 命令有一个 .PEEK 选项,该选项将明确不设置 /Seen 标志。

查看RFC 3501 中的 FETCH 命令并向下滚动位至第 57 页或搜索“BODY.PEEK”。

There is a .PEEK option on the FETCH command in IMAP that will explicitly not set the /Seen flag.

Look at the FETCH command in RFC 3501 and scroll down a bit to page 57 or search for "BODY.PEEK".

最佳男配角 2024-08-15 04:13:12

使用BODY.PEEK时需要指定截面。 IMAP Fetch Command< 中解释了各个部分/a> BODY[

]<> 下的文档

import getpass, imaplib

M = imaplib.IMAP4()
M.login(getpass.getuser(), getpass.getpass())
M.select()
typ, data = M.search(None, 'ALL')
for num in data[0].split():
    typ, data = M.fetch(num, '(BODY.PEEK[])')
    print 'Message %s\n%s\n' % (num, data[0][5])
M.close()
M.logout()

PS:我想修复给出的答案 Gene Wood 但不允许,因为编辑较小超过 6 个字符 (BODY.PEEK -> BODY.PEEK[])

You need to specify section when you use BODY.PEEK. Sections are explained in IMAP Fetch Command documentations under BODY[<section>]<<partial>>

import getpass, imaplib

M = imaplib.IMAP4()
M.login(getpass.getuser(), getpass.getpass())
M.select()
typ, data = M.search(None, 'ALL')
for num in data[0].split():
    typ, data = M.fetch(num, '(BODY.PEEK[])')
    print 'Message %s\n%s\n' % (num, data[0][5])
M.close()
M.logout()

PS: I wanted to fix answer given Gene Wood but was not allowed because edit was smaller than 6 characters (BODY.PEEK -> BODY.PEEK[])

纸伞微斜 2024-08-15 04:13:12

没有人使用 POP,因为他们通常想要 IMAP 的额外功能,例如跟踪邮件状态。当该功能只会妨碍您并且需要解决方法时,我认为使用 POP 是您最好的选择!-)

Nobody uses POP because typically they want the extra functionality of IMAP, such as tracking message state. When that functionality is only getting in your way and needs workarounds, I think using POP's your best bet!-)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文