【问题标题】:IMAP search for address is equal not containsIMAP 搜索地址等于不包含
【发布时间】:2018-10-04 22:13:33
【问题描述】:

=)

我需要从具有特定地址的电子邮件收件箱中获取所有消息。 为此我使用命令:

self.server.search(None, '(HEADER FROM "test@gmail.com")')

它可以工作,但是当我尝试查找消息表单 st@gmail.com 时,我得到了相同的结果。而且我知道用这个标准我搜索所有消息都包含特定的字符串。但对我来说test@gmail.comst@gmail.com 是不同的地址。如何搜索 EQUAL 而不是 CONTAINS 地址?

import imaplib
self.server = imaplib.IMAP4(self.imap_ssl_host, self.imap_ssl_port)    

【问题讨论】:

  • self是什么类型的?
  • 我错了。 import imaplibself.server = imaplib.IMAP4(self.imap_ssl_host, self.imap_ssl_port)

标签: python imap


【解决方案1】:

您可以尝试搜索<test@gmail.com> 而不是test@gmail.com

来自 test@gmail.com 的消息通常显示为 From: Firstname Lastname <test@gmail.com>,其中包含子字符串 <test@,并且大多数 IMAP 搜索都是子字符串搜索,包括 FROM。如果这个 hack 对您和您使用的任何服务器都足够了,那么对您有好处,否则您需要进行客户端过滤以消除误报。

【讨论】:

  • 对于我的情况它不起作用=(但是感谢您的回答,也许它对其他人有用
猜你喜欢
  • 2012-03-24
  • 2011-08-18
  • 1970-01-01
  • 1970-01-01
  • 2012-05-20
  • 1970-01-01
  • 2016-05-29
  • 2023-03-31
  • 1970-01-01
相关资源
最近更新 更多