Esempio n. 1
0
 /**
  * 
  * @param imap $imap 
  * @param type $x
  */
 public function parseMessage($imap, $x)
 {
     $imap->mail->noop();
     try {
         $message = $imap->mail->getMessage($x);
     } catch (Exception $e) {
         log::error($e->getMessage());
         return false;
     }
     $imap->mail->noop();
     $parts = $imap->getAllParts($message);
     // check for valid message/delivery-status'
     if (!isset($parts['message/delivery-status'][0])) {
         log::debug("No delivery status");
         return false;
     } else {
         $delivery_status = $parts['message/delivery-status'][0];
     }
     $email = self::getBounceEmail($delivery_status);
     if ($email) {
         log::error("Found email in message: {$email}");
         $bean = rb::getBean('mailerbounce');
         $bean->deleted = 0;
         // get bounce code e.g 4.4.2 hotmail
         $bounce_code = trim(self::getBounceCode($delivery_status));
         if ($bounce_code) {
             $bounce_ary = explode('.', $bounce_code);
             $bean->major = $bounce_ary[0];
             $bean->minor = $bounce_ary[1];
             $bean->part = $bounce_ary[2];
             $bean->bouncecode = $bounce_code;
         } else {
             $bean->bouncecode = null;
         }
         $bean->email = $email;
         $bean->bouncedate = date::getDateNow(array('hms' => true));
         $bean->message = $delivery_status;
         $bean->returnpath = $message->getHeader('return-path', 'string');
         R::store($bean);
         log::debug("Stored user with email: {$email}. {$bounce_code}" . PHP_EOL);
     } else {
         log::error("Did not get a mail from message: " . $delivery_status);
     }
     return true;
 }
Esempio n. 2
0
 /**
  * method to execute a query, insert update or delte. 
  * @return boolean true on success and false on failure. 
  */
 public static function exec()
 {
     self::$debug[] = self::$query;
     self::$stmt = self::$dbh->prepare(self::$query);
     try {
         self::prepare();
         $res = self::$stmt->execute();
     } catch (Exception $e) {
         $message = $e->getMessage();
         $message .= $e->getTraceAsString();
         log::debug($message);
         $last = self::getLastDebug();
         log::debug($last);
         die;
     }
     self::unsetVars();
     return $res;
 }