有没有更好的方法来监视 IMAP 邮箱的更新?

huangapple go评论90阅读模式
英文:

Any better way to watch imap email box update?

问题

我尝试了IMAP的空闲方式,大部分时间都有效,但是:

  1. 有时会丢失事件... IDLE监视的状态更新是延迟的消息,导致我的脚本混乱。
  2. 电子邮件ISP有时会关闭IMAP连接,连接可能只持续几分钟。
  3. 当大量电子邮件涌入时,例如每秒钟一个电子邮件,IDLE状态会丢失很多事件。

我知道这可能主要是电子邮件ISP的问题,但是否有更好的方法可以及时可靠地获取电子邮件通知。

或者我只能使用困难的方式,长时间循环检查电子邮件?

英文:

I have tried IMAP idle way, which works in most time, but:

  1. Sometimes it's missing event... the status updated which IDLE watched it's a delayed message, make my script confused.
  2. The email ISP sometimes close the imap conneciton, connection maybe just last serveral minutes.
  3. When lots email rush in, such as one email per seconds. IDLE status missing lot's event.

I know this is maybe mostly should blame email ISP, but is there a better way I can get email notification in time and reliable.

or I just use hard way, long loop check email?

答案1

得分: 2

IDLE不会告诉你有一条新消息,它只会告诉你发生了某些事情。这可能是一条新消息,也可能是十条;可能是一条消息被删除,也可能是十条;或者可能是其他的变化。你需要自己去检查。(如果你想测试你的代码如何处理这种情况,你可以使用UID COPYEXPUNGE来引发大的变化。)

连接关闭也是你需要解决的问题。IMAP服务器可以关闭连接(出于好或坏的原因),但通常是由客户所属的NAT中间盒子来完成。只有客户端可以重新连接以解决NAT问题,解决NAT问题也会作为副作用解决服务器问题。

英文:

IDLE doesn't tell you that there is one new message, it tells you that something happened. It may be one new message, or ten, it may be one message being deleted, or ten, or it may be another change. It's up to you to check. (If you want to test how your code handles it, you can cause large changes using UID COPY and EXPUNGE.)

Connections being closed is also your problem to solve. The IMAP server can close a connection (for good or bad reasons), but usually it's done by a NAT middlebox belonging to the customer. Only the client can reconnect to solve the NAT problem, and solving the NAT problem solves the server problem too, as a side effect.

huangapple
  • 本文由 发表于 2017年4月7日 17:07:38
  • 转载请务必保留本文链接:https://go.coder-hub.com/43274124.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定