该功能imap_search()
可以帮助您,但请记住,它需要得到 IMAP 服务器的支持才能工作。
更新:
这是小程序:
error_reporting(E_ALL);
ini_set('display_errors', '1');
$user = ''; // put your Gmail email address here (including '@gmail.com');
$pass = ''; // put your Gmail password here
$host = 'imap.gmail.com:993'; // Put your IMAP server here with portGmail
$keyword = ''; // put the word you want to find
$mailbox = sprintf('{%s/imap/ssl/user=%s}INBOX', $host, $user);
$query = sprintf('BODY "%s"', $keyword);
$mbox = imap_open($mailbox, $user, $pass, OP_READONLY);
if ($mbox) {
$list = imap_search($mbox, $query, SE_UID);
var_dump($list);
imap_close($mbox);
}
它可能适用于您的设置,也可能不适用于您的设置。它在我们公司的邮件服务器上使用一个帐户对我有用。它无法连接到与我的常规电子邮件客户端正常工作的另一台服务器上。
它与Gmail同时工作和失败(!!)。不要问!