0
以下是一個示例電子郵件。什麼我想是使用Zend郵件過濾掉的電子郵件與特定的標題和主題做的,這裏是我的REG表達研究如何使用zend郵件來操縱郵件消息?
$pattern_subject = "#delivery errors|delivery failure|delivery has failed|delivery notification|delivery problem|delivery status notif|failure delivery|failure notice|mail delivery failed|mail delivery system|mail status report|mail system error|mail transaction failed|mailserver notification|mdaemon notification|nondeliverable mail|returned email|returned mail|returned mail|returned to sender|returning message to sender|spam eater|undeliverable|undelivered mail|warning: message#i";
$pattern_body = "#554 delivery error|554 TRANSACTION FAILED|Action: failed|Delivery attempts will continue to be made for|delivery temporarily suspended|Invalid recipient|is not a valid mailbox|Mail rejected by Windows Live Hotmail for policy reasons|mailbox is full|Mailbox quota usage exceeded|mailbox unavailable|my badmailfrom list|no mailbox here by that name|no such address|No such user here|not yet been delivered|Over quota|PERM_FAILURE: DNS Error: Domain name not found|Recipient address rejected|retry timeout exceeded|Status: 4.4.1|The account or domain may not exist, they may be blacklisted, or missing the proper dns entries.|The following address doesn't exist|The message that you sent was undeliverable to the following|The recipient name is not recognized|This Gmail user does not exist|This is a permanent error|Unrouteable address|unrouteable mail domain|User mailbox exceeds allowed size|User unknown in virtual alias table|User unknown#i";
一個用於主題,一個用於身體,我怎麼能
1)使用它們來過濾郵件並只獲得與reg exp匹配的內容?
2)獲取的郵件用不同的一部分,我需要的是單獨的
接收日期,標題,正文
這裏是我試過的代碼(忽略了IMAP設置),但它只打印出標題並且未被過濾。
foreach ($mail as $message) {
foreach ($message->getHeaders() as $name => $value) {
if (is_string($pattern_subject)) {
echo "$name: $value\n";
echo "<br>";
}
}
}
謝謝