İşte IMAP kullanarak sekerek işlemek için bir konserve çözümdür.
Ben özel bir bounce@xxxxxx.us benim Posta örneğinin Return-Path başlığı değişti
Beni canlı düşünmek için yeterince kolay tek yöntem POP3 üzerinden adanmış gelen kutusunu kontrol eder ve alınan mesaj dayalı her e-posta işleyebilir, hangi şudur.
$inst=pop3_login('mail.xxxxxx.us','110','bounce@xxxxxx.us','pass');
$stat=pop3_stat($inst);
//print_r($stat);
if($stat['Unread']>0){
echo "begin process<br><br>";
$list=pop3_list($inst);
//print_r($list);
foreach($list as $row){
if(strpos($row['from'],'MAILER-DAEMON')!==FALSE){
$msg=imap_fetchbody($inst,$row['msgno'],'1');
if(strpos($msg,'550')!==FALSE){
echo "handle hard bounce".$msg."<br><br>";
//WHATEVER HERE TO PROCESS BOUNCE
}
}
else{
$msg=imap_fetchbody($inst,$row['msgno'],'1');
echo "not from my server. could be spam, etc.".$msg."<br><br>";
//PROBABLY NO ACTION IS NEEDED
}
//AFTER PROCESSING
//imap_delete ( resource $imap_stream , int $msg_number [, int $options = 0 ] )
//commented out because I havent implemented yet. see IMAP documentation
}
}
else{
echo "no unread messages";
}
//imap_close ( resource $imap_stream [, int $flag = 0 ] )
//commented out because I havent implemented yet. see IMAP documentation.
//flag: If set to CL_EXPUNGE, the function will silently expunge the mailbox before closing, removing all messages marked for deletion. You can achieve the same thing by using imap_expunge()
function pop3_login($host,$port,$user,$pass,$folder="INBOX",$ssl=false)
{
$ssl=($ssl==false)?"/novalidate-cert":"";
return (imap_open("{"."$host:$port/pop3$ssl"."}$folder",$user,$pass));
}
function pop3_stat($connection)
{
$check = imap_mailboxmsginfo($connection);
return ((array)$check);
}
function pop3_list($connection,$message="")
{
if ($message)
{
$range=$message;
} else {
$MC = imap_check($connection);
$range = "1:".$MC->Nmsgs;
}
$response = imap_fetch_overview($connection,$range);
foreach ($response as $msg) $result[$msg->msgno]=(array)$msg;
return $result;
}
function pop3_retr($connection,$message)
{
return(imap_fetchheader($connection,$message,FT_PREFETCHTEXT));
}
function pop3_dele($connection,$message)
{
return(imap_delete($connection,$message));
}