PHP IMAP:如何使用IMAP和PHP从gmail检索电子邮件时阻止提取图像

时间:2016-09-14 09:57:39

标签: php gmail imap

我正在从我的Gmail收件箱中检索电子邮件的正文,但我并不想要它来获取图片(用于跟踪保护)。我保留了不在Gmail设置选项中显示图片的设置,但它对IMAP不起作用。如果可能的话,请通过PHP等建议一条出路。

<?php
$server = "{imap.gmail.com:993/ssl}INBOX";
$yourEmail = "xyz@gmail.com";
$yourEmailPassword = "abc123";
$mailbox = imap_open($server, $yourEmail, $yourEmailPassword);
$mail = imap_search($mailbox,'SUBJECT "abc"');
$count = count($mail);
echo "<h3>Total number of emails is $count</h3><br>";
rsort($mail);
for ($x = 0; $x < $count; $x++) {
$mail_headers = imap_headerinfo($mailbox, $mail[$x]);
$to = $mail_headers->toaddress;
#$message = quoted_printable_decode(imap_fetchbody($mailbox,$mail[$x],1));
$message = quoted_printable_decode(imap_fetchbody($mailbox,$mail[$x],2));
echo "$message<br>";
}
imap_close($mailbox);
?>

0 个答案:

没有答案