[ Index ]

MailPress 544

[ Index ]     [ Classes ]     [ Functions ]     [ Variables ]     [ Constants ]     [ Statistics ]    

title

Body

[close]

/mp-includes/class/ -> MP_Bounce.class.php (source)

   1  <?php
   2  class MP_Bounce extends MP_bounce_
   3  {
   4      public $option_name     = MailPress_bounce_handling::option_name;
   5      public $option_name_pop3= MailPress_bounce_handling::option_name_pop3;
   6      public $meta_key         = MailPress_bounce_handling::meta_key;
   7  
   8      public $class        = __CLASS__;
   9      public $log_name         = 'mp_process_bounce_handling';
  10      public $log_option_name = 'bounce_handling';
  11      public $log_title     = 'Bounce Handling Report (Bounce in mailbox : %1$s )';
  12  
  13      public $cron_name     = 'MailPress_schedule_bounce_handling';
  14  
  15  	function is_bounce()
  16      {
  17          $tags = array('Return-Path', 'Return-path', 'Received', 'To', 'X-Failed-Recipients', 'Final-Recipient');
  18          $this->pop3->get_headers_deep($this->message_id, $tags);
  19  
  20          $prefix     = preg_quote(substr($this->config['Return-Path'], 0, strpos($this->config['Return-Path'], '@')) . '+');
  21          $domain     = preg_quote(substr($this->config['Return-Path'], strpos($this->config['Return-Path'], '@') + 1 ));
  22          $user_mask    = preg_quote('{{_user_id}}');
  23  
  24          foreach($this->pop3->headers as $tag => $headers)
  25          {
  26              foreach($headers as $header)
  27              {
  28                  if (strpos($header, $this->config['Return-Path']) !== false) continue;
  29  
  30                  switch (true)
  31                  {
  32                      case (preg_match("#{$prefix}[0-9]*\+[0-9]*@{$domain}#", $header)) :
  33                          preg_match_all("/{$prefix}([0-9]*)\+([0-9]*)@{$domain}/", $header, $matches, PREG_SET_ORDER);
  34                          if (empty($matches)) continue 2;
  35                          $bounce_email    = $matches[0][0];
  36                          $mail_id        = $matches[0][1];
  37                          $mp_user_id        = $matches[0][2];
  38                      break;
  39                      case (preg_match("#{$prefix}[0-9]*\+$user_mask@{$domain}#", $header)) :
  40                          preg_match_all("/$prefix([0-9]*)\+$user_mask@$domain/", $header, $matches, PREG_SET_ORDER);
  41                          if (empty($matches)) continue 2;
  42                          $bounce_email    = $matches[0][0];
  43                          $mail_id        = $matches[0][1];
  44                          if (!$mail = MP_Mail::get($mail_id)) continue 2;
  45                          if (!is_email($mail->toemail))        continue 2;
  46                          $mp_user_id     = MP_User::get_id_by_email($mail->toemail);
  47                          if (!$mp_user_id) continue 2;
  48                      break;
  49                      case (preg_match_all("/[a-zA-Z0-9!#$%&\'*+\/=?^_`{|}~\.-]+@[\._a-zA-Z0-9-]{2,}+/i", $header, $matches, PREG_SET_ORDER) && ($bounce_email = is_email($matches[0][0])) ) :
  50                          switch($tag)
  51                          {
  52                              case 'X-Failed-Recipients' :
  53                              case 'Final-Recipient' :
  54                                  $mail_id = -1;
  55                                  $mp_user_id = MP_User::get_id_by_email($bounce_email);
  56                                  if (!$mp_user_id) continue 3;
  57                              break;
  58                              default :
  59                                  continue 3;
  60                              break;
  61                          }
  62                      break;
  63                      default :
  64                          continue 2;
  65                      break;
  66                  }
  67              }
  68  
  69              if (isset($mail_id, $mp_user_id, $bounce_email))
  70              {
  71                  $this->process_mailbox_status();
  72                  return array($mail_id, $mp_user_id, $bounce_email);
  73                  break;
  74              }
  75          }
  76          return false;
  77      }
  78  }


Generated: Thu Apr 28 18:38:52 2016 Cross-referenced by PHPXref 0.7.1