2

我想跟踪从我的服务器发送的退回邮件。我看了一些东西,发现被退回的电子邮件存储在邮箱中,可以通过直接读取邮箱文件来检测。

使用 php 检查退回的邮件

现在我想知道如何读取服务器的邮箱文件?发送邮件后是否需要手动运行 php 脚本文件以将退回的电子邮件记录到我的数据库中?我是否需要解析电子邮件内容以找出被退回的电子邮件?

我的目标是为我的 php 服务器提供流行电子邮件访问权限。

4

1 回答 1

2

这是我连接到 one.com 上的传入邮件服务器的方法

$inbox = imap_open('{imap.one.com:993/imap/ssl/novalidate-cert}INBOX', 'your@address.com', 'xxxxxxxx') or die('Cannot connect: ' . print_r(imap_errors(), true));

/* grab emails */
$emails = imap_search($inbox,'ALL');

/* if emails are returned, cycle through each... */
if($emails) {

    /* put the newest emails on top */
    rsort($emails);

    /* for every email... */
    foreach($emails as $email_number) {

        $message = imap_fetchbody($inbox,$email_number,2);

        $pieces = explode(" ", $message);

        foreach($pieces as $piece){

            $findme   = '@';
            //$findme2 = '.com';

            $pos = strpos($piece, $findme);

            if ($pos !== false) {
                    echo $piece;
            }


        }

    }

}

退回的电子邮件地址在邮件正文中,我将其回显到浏览器。

于 2015-09-10T17:33:04.930 回答