Пример #1
0
 /**
  * Detect original email by references headers
  * 
  * @see http://th-h.de/faq/headerfaq.php#technisches
  * @param Mzax_Bounce_Message $message
  * @return Mzax_Emarketing_Model_Outbox_Email|NULL
  */
 public function detectReferenceEmail(Mzax_Bounce_Message $message)
 {
     /* @var $email Mzax_Emarketing_Model_Outbox_Email */
     $email = Mage::getModel('mzax_emarketing/outbox_email');
     // try to load original email by reference header
     foreach (array_reverse($message->getReferences()) as $messageId) {
         $email->loadByMessageId($messageId);
         if ($email->getId()) {
             return $email;
         }
     }
     // try using in reply header
     $inReplyTo = $message->getHeader('in-reply-to');
     if (preg_match('/<(.+)>/', $inReplyTo, $match)) {
         $email->loadByMessageId($match[1]);
         if ($email->getId()) {
             return $email;
         }
     }
     return null;
 }