如何显示发送到网站上的电子邮件地址的所有内容?

时间:2010-04-05 22:40:30

标签: php email

我想显示网站上收到的所有电子邮件主题。有一个开源的“pop to php”脚本吗?还是我可以直接使用的服务?

任何帮助表示赞赏!谢谢!

1 个答案:

答案 0 :(得分:2)

我会使用内置的PHP IMAP函数。以下是您的示例:

$mbox = imap_open ("{yourserver.com:110/pop3/novalidate-cert}INBOX", "my@email.com", "myPassword");
if (!$mbox) {
    return false;
}
$m_search = imap_search($mbox, 'UNDELETED');
        $messages = array();
        if($m_search < 1) {
            return 'No New Messages';
        } else {
            foreach ($m_search as $item) {
                $headers = imap_headerinfo($mbox, $item);
                $struct = imap_fetchstructure($mbox, $item);
                $body = imap_body($mbox, $item);

                $headers->subtype = $struct->subtype;
                $headers->body = $body;

                $messages[] = $headers;

            }
        }

        imap_close($mbox);