[ Index ] |
MailPress 7.2 |
[ Index ] [ Classes ] [ Functions ] [ Variables ] [ Constants ] [ Statistics ] |
[Summary view] [Print] [Text view]
1 <?php 2 class MP_Bounce extends MP_bounce_ 3 { 4 public $option_name = MailPress_bounce_handling::option_name; 5 6 public $class = __CLASS__; 7 public $log_name = MailPress_bounce_handling::process_name; 8 public $log_option_name = 'bounce_handling'; 9 public $log_title = 'Bounce Handling Report ( Bounce in mailbox : %1$s )'; 10 11 public $cron_name = 'MailPress_schedule_bounce_handling'; 12 13 public $meta_key = MailPress_bounce_handling::meta_key; 14 15 const headers = array( 'Subject', 'Return-Path', 'Return-path', 'Received', 'To', 'X-Failed-Recipients', 'Final-Recipient' ); 16 17 function is_bounce() 18 { 19 $prefix = preg_quote( substr( $this->config['Return-Path'], 0, strpos( $this->config['Return-Path'], '@' ) ) . '+' ); 20 $domain = preg_quote( substr( $this->config['Return-Path'], strpos( $this->config['Return-Path'], '@' ) + 1 ) ); 21 $user_mask = preg_quote( '{{_user_id}}' ); 22 23 $this->pop3->get_headers_deep( $this->message_id, self::headers ); 24 25 $this->bounce_email = false; 26 $this->mail_id = false; 27 $this->mp_user_id = false; 28 29 // subject 30 $subject = $this->pop3->get_header( 'Subject' ); 31 32 if ( empty( $subject ) ) 33 { 34 $bm = ' ! ** ERROR ** empty header : Subject (?) '; 35 $this->local_log[] = '!' . $bm . str_repeat( ' ', $this->bt - strlen( $bm ) ) . '!'; 36 return false; 37 } 38 39 $bm = ' Subject ! ==> ' . $subject; 40 $this->local_log[] = '!' . $bm . str_repeat( ' ', $this->bt - strlen( $bm ) ) . '!'; 41 42 foreach( $this->pop3->headers as $tag => $headers ) 43 { 44 if ( $tag == 'Subject' ) continue; 45 foreach( $headers as $header ) 46 { 47 if ( strpos( $header, $this->config['Return-Path'] ) !== false ) continue; 48 49 switch ( true ) 50 { 51 case ( preg_match( "#{$prefix}[0-9]*\+[0-9]*@{$domain}#", $header ) ) : 52 preg_match_all( "/{$prefix}([0-9]*)\+([0-9]*)@{$domain}/", $header, $matches, PREG_SET_ORDER ); 53 if ( empty( $matches ) ) continue 2; 54 55 $this->bounce_email = $matches[0][0]; 56 $this->mail_id = $matches[0][1]; 57 $this->mp_user_id = $matches[0][2]; 58 break; 59 case ( preg_match( "#{$prefix}[0-9]*\+$user_mask@{$domain}#", $header ) ) : 60 preg_match_all( "/$prefix([0-9]*)\+$user_mask@$domain/", $header, $matches, PREG_SET_ORDER ); 61 if ( empty( $matches ) ) continue 2; 62 63 $this->bounce_email = $matches[0][0]; 64 $this->mail_id = $matches[0][1]; 65 if ( !$mail = MP_Mail::get( $this->mail_id ) ) continue 2; 66 if ( !MailPress::is_email( $mail->toemail ) ) continue 2; 67 $this->mp_user_id = MP_User::get_id_by_email( $mail->toemail ); 68 if ( !$this->mp_user_id ) continue 2; 69 break; 70 case ( preg_match_all( "/[a-zA-Z0-9!#$%&\'*+\/=?^_`{|}~\.-]+@[\._a-zA-Z0-9-]{2,}+/i", $header, $matches, PREG_SET_ORDER ) && ( $this->bounce_email = MailPress::is_email( $matches[0][0] ) ) ) : 71 switch( $tag ) 72 { 73 case 'X-Failed-Recipients' : 74 case 'Final-Recipient' : 75 76 $this->mail_id = -1; 77 $this->mp_user_id = MP_User::get_id_by_email( $this->bounce_email ); 78 if ( !$this->mp_user_id ) continue 3; 79 break; 80 default : 81 continue 3; 82 break; 83 } 84 break; 85 default : 86 continue 2; 87 break; 88 } 89 } 90 91 if ( $this->mail_id && $this->mp_user_id && $this->bounce_email ) 92 { 93 break; 94 } 95 } 96 97 return ( $this->mail_id && $this->mp_user_id && $this->bounce_email ); 98 } 99 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Tue May 19 15:55:14 2020 | Cross-referenced by PHPXref 0.7.1 |