How to display everything that is sent to an email address on a website?
I would like to display all the subjects of email received on a website. Is there an open source "pop to php" script? Or a service I can use di开发者_开发问答rectly?
Any help is appreciated! thanks!
I would use the built-in PHP IMAP functions. Here's a sample for you:
$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);
精彩评论