@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | */ |
17 | 17 | namespace BounceMailHandler; |
18 | 18 | |
19 | -require_once __DIR__ . '/phpmailer-bmh_rules.php'; |
|
19 | +require_once __DIR__.'/phpmailer-bmh_rules.php'; |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * BounceMailHandler class |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | { |
278 | 278 | // before starting the processing, let's check the delete flag and do global deletes if true |
279 | 279 | if (trim($this->deleteMsgDate) != '') { |
280 | - echo 'processing global delete based on date of ' . $this->deleteMsgDate . '<br />'; |
|
280 | + echo 'processing global delete based on date of '.$this->deleteMsgDate.'<br />'; |
|
281 | 281 | $this->globalDelete(); |
282 | 282 | } |
283 | 283 | |
@@ -287,23 +287,23 @@ discard block |
||
287 | 287 | $this->moveHard = false; |
288 | 288 | } |
289 | 289 | |
290 | - $port = $this->port . '/' . $this->service . '/' . $this->serviceOption; |
|
290 | + $port = $this->port.'/'.$this->service.'/'.$this->serviceOption; |
|
291 | 291 | |
292 | 292 | set_time_limit(6000); |
293 | 293 | |
294 | 294 | if (!$this->testMode) { |
295 | - $this->mailboxLink = imap_open('{' . $this->mailhost . ':' . $port . '}' . $this->boxname, $this->mailboxUserName, $this->mailboxPassword, CL_EXPUNGE | ($this->testMode ? OP_READONLY : 0)); |
|
295 | + $this->mailboxLink = imap_open('{'.$this->mailhost.':'.$port.'}'.$this->boxname, $this->mailboxUserName, $this->mailboxPassword, CL_EXPUNGE | ($this->testMode ? OP_READONLY : 0)); |
|
296 | 296 | } else { |
297 | - $this->mailboxLink = imap_open('{' . $this->mailhost . ':' . $port . '}' . $this->boxname, $this->mailboxUserName, $this->mailboxPassword, ($this->testMode ? OP_READONLY : 0)); |
|
297 | + $this->mailboxLink = imap_open('{'.$this->mailhost.':'.$port.'}'.$this->boxname, $this->mailboxUserName, $this->mailboxPassword, ($this->testMode ? OP_READONLY : 0)); |
|
298 | 298 | } |
299 | 299 | |
300 | 300 | if (!$this->mailboxLink) { |
301 | - $this->errorMessage = 'Cannot create ' . $this->service . ' connection to ' . $this->mailhost . $this->bmhNewLine . 'Error MSG: ' . imap_last_error(); |
|
301 | + $this->errorMessage = 'Cannot create '.$this->service.' connection to '.$this->mailhost.$this->bmhNewLine.'Error MSG: '.imap_last_error(); |
|
302 | 302 | $this->output(); |
303 | 303 | |
304 | 304 | return false; |
305 | 305 | } else { |
306 | - $this->output('Connected to: ' . $this->mailhost . ' (' . $this->mailboxUserName . ')'); |
|
306 | + $this->output('Connected to: '.$this->mailhost.' ('.$this->mailboxUserName.')'); |
|
307 | 307 | |
308 | 308 | return true; |
309 | 309 | } |
@@ -319,14 +319,14 @@ discard block |
||
319 | 319 | $dateArr = explode('-', $this->deleteMsgDate); // date format is yyyy-mm-dd |
320 | 320 | $delDate = mktime(0, 0, 0, $dateArr[1], $dateArr[2], $dateArr[0]); |
321 | 321 | |
322 | - $port = $this->port . '/' . $this->service . '/' . $this->serviceOption; |
|
323 | - $mboxt = imap_open('{' . $this->mailhost . ':' . $port . '}', $this->mailboxUserName, $this->mailboxPassword, OP_HALFOPEN); |
|
322 | + $port = $this->port.'/'.$this->service.'/'.$this->serviceOption; |
|
323 | + $mboxt = imap_open('{'.$this->mailhost.':'.$port.'}', $this->mailboxUserName, $this->mailboxPassword, OP_HALFOPEN); |
|
324 | 324 | |
325 | 325 | if ($mboxt === false) { |
326 | 326 | return false; |
327 | 327 | } |
328 | 328 | |
329 | - $list = imap_getmailboxes($mboxt, '{' . $this->mailhost . ':' . $port . '}', '*'); |
|
329 | + $list = imap_getmailboxes($mboxt, '{'.$this->mailhost.':'.$port.'}', '*'); |
|
330 | 330 | |
331 | 331 | if (is_array($list)) { |
332 | 332 | foreach ($list as $key => $val) { |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | $nameRaw = $nameArr[count($nameArr) - 1]; |
336 | 336 | |
337 | 337 | if (!stristr($nameRaw, 'sent')) { |
338 | - $mboxd = imap_open('{' . $this->mailhost . ':' . $port . '}' . $nameRaw, $this->mailboxUserName, $this->mailboxPassword, CL_EXPUNGE); |
|
338 | + $mboxd = imap_open('{'.$this->mailhost.':'.$port.'}'.$nameRaw, $this->mailboxUserName, $this->mailboxPassword, CL_EXPUNGE); |
|
339 | 339 | $messages = imap_sort($mboxd, SORTDATE, 0); |
340 | 340 | $i = 0; |
341 | 341 | |
@@ -375,9 +375,9 @@ discard block |
||
375 | 375 | { |
376 | 376 | if ($this->verbose >= $verboseLevel) { |
377 | 377 | if (empty($msg)) { |
378 | - echo $this->errorMessage . $this->bmhNewLine; |
|
378 | + echo $this->errorMessage.$this->bmhNewLine; |
|
379 | 379 | } else { |
380 | - echo $msg . $this->bmhNewLine; |
|
380 | + echo $msg.$this->bmhNewLine; |
|
381 | 381 | } |
382 | 382 | } |
383 | 383 | } |
@@ -400,12 +400,12 @@ discard block |
||
400 | 400 | } |
401 | 401 | |
402 | 402 | if (!$this->mailboxLink) { |
403 | - $this->errorMessage = 'Cannot open the mailbox file to ' . $filePath . $this->bmhNewLine . 'Error MSG: ' . imap_last_error(); |
|
403 | + $this->errorMessage = 'Cannot open the mailbox file to '.$filePath.$this->bmhNewLine.'Error MSG: '.imap_last_error(); |
|
404 | 404 | $this->output(); |
405 | 405 | |
406 | 406 | return false; |
407 | 407 | } else { |
408 | - $this->output('Opened ' . $filePath); |
|
408 | + $this->output('Opened '.$filePath); |
|
409 | 409 | |
410 | 410 | return true; |
411 | 411 | } |
@@ -443,12 +443,12 @@ discard block |
||
443 | 443 | $unprocessedCount = 0; |
444 | 444 | $deletedCount = 0; |
445 | 445 | $movedCount = 0; |
446 | - $this->output('Total: ' . $totalCount . ' messages '); |
|
446 | + $this->output('Total: '.$totalCount.' messages '); |
|
447 | 447 | |
448 | 448 | // process maximum number of messages |
449 | 449 | if ($fetchedCount > $this->maxMessages) { |
450 | 450 | $fetchedCount = $this->maxMessages; |
451 | - $this->output('Processing first ' . $fetchedCount . ' messages '); |
|
451 | + $this->output('Processing first '.$fetchedCount.' messages '); |
|
452 | 452 | } |
453 | 453 | |
454 | 454 | if ($this->testMode) { |
@@ -485,7 +485,7 @@ discard block |
||
485 | 485 | $processed = $this->processBounce($x, 'DSN', $totalCount); |
486 | 486 | } else { |
487 | 487 | // not standard DSN msg |
488 | - $this->output('Msg #' . $x . ' is not a standard DSN message', self::VERBOSE_REPORT); |
|
488 | + $this->output('Msg #'.$x.' is not a standard DSN message', self::VERBOSE_REPORT); |
|
489 | 489 | |
490 | 490 | if ($this->debugBodyRule) { |
491 | 491 | if ($structure->ifdescription) { |
@@ -507,7 +507,7 @@ discard block |
||
507 | 507 | $processed = $this->processBounce($x, 'DSN', $totalCount); |
508 | 508 | } else { |
509 | 509 | // not standard DSN msg |
510 | - $this->output('Msg #' . $x . ' is not a standard DSN message', self::VERBOSE_REPORT); |
|
510 | + $this->output('Msg #'.$x.' is not a standard DSN message', self::VERBOSE_REPORT); |
|
511 | 511 | |
512 | 512 | if ($this->debugBodyRule) { |
513 | 513 | $this->output(" Content-Type : {$match[1]}", self::VERBOSE_DEBUG); |
@@ -517,10 +517,10 @@ discard block |
||
517 | 517 | } |
518 | 518 | } else { |
519 | 519 | // didn't get content-type header |
520 | - $this->output('Msg #' . $x . ' is not a well-formatted MIME mail, missing Content-Type', self::VERBOSE_REPORT); |
|
520 | + $this->output('Msg #'.$x.' is not a well-formatted MIME mail, missing Content-Type', self::VERBOSE_REPORT); |
|
521 | 521 | |
522 | 522 | if ($this->debugBodyRule) { |
523 | - $this->output(' Headers: ' . $this->bmhNewLine . $header . $this->bmhNewLine, self::VERBOSE_DEBUG); |
|
523 | + $this->output(' Headers: '.$this->bmhNewLine.$header.$this->bmhNewLine, self::VERBOSE_DEBUG); |
|
524 | 524 | } |
525 | 525 | |
526 | 526 | $processed = $this->processBounce($x, 'BODY', $totalCount); |
@@ -589,15 +589,15 @@ discard block |
||
589 | 589 | flush(); |
590 | 590 | } |
591 | 591 | |
592 | - $this->output($this->bmhNewLine . 'Closing mailbox, and purging messages'); |
|
592 | + $this->output($this->bmhNewLine.'Closing mailbox, and purging messages'); |
|
593 | 593 | |
594 | 594 | imap_close($this->mailboxLink); |
595 | 595 | |
596 | - $this->output('Read: ' . $fetchedCount . ' messages'); |
|
597 | - $this->output($processedCount . ' action taken'); |
|
598 | - $this->output($unprocessedCount . ' no action taken'); |
|
599 | - $this->output($deletedCount . ' messages deleted'); |
|
600 | - $this->output($movedCount . ' messages moved'); |
|
596 | + $this->output('Read: '.$fetchedCount.' messages'); |
|
597 | + $this->output($processedCount.' action taken'); |
|
598 | + $this->output($unprocessedCount.' no action taken'); |
|
599 | + $this->output($deletedCount.' messages deleted'); |
|
600 | + $this->output($movedCount.' messages moved'); |
|
601 | 601 | |
602 | 602 | return true; |
603 | 603 | } |
@@ -695,7 +695,7 @@ discard block |
||
695 | 695 | break; |
696 | 696 | |
697 | 697 | default: // unsupport Content-type |
698 | - $this->output('Msg #' . $pos . ' is unsupported Content-Type:' . $structure->type, self::VERBOSE_REPORT); |
|
698 | + $this->output('Msg #'.$pos.' is unsupported Content-Type:'.$structure->type, self::VERBOSE_REPORT); |
|
699 | 699 | |
700 | 700 | return false; |
701 | 701 | } |
@@ -742,7 +742,7 @@ discard block |
||
742 | 742 | } |
743 | 743 | |
744 | 744 | if ($this->testMode) { |
745 | - $this->output('Match: ' . $ruleNumber . ':' . $ruleCategory . '; ' . $bounceType . '; ' . $email); |
|
745 | + $this->output('Match: '.$ruleNumber.':'.$ruleCategory.'; '.$bounceType.'; '.$email); |
|
746 | 746 | } else { |
747 | 747 | // code below will use the Callback function, but return no value |
748 | 748 | $params = array( |
@@ -767,7 +767,7 @@ discard block |
||
767 | 767 | } else { |
768 | 768 | // match rule, do bounce action |
769 | 769 | if ($this->testMode) { |
770 | - $this->output('Match: ' . $ruleNumber . ':' . $ruleCategory . '; ' . $bounceType . '; ' . $email); |
|
770 | + $this->output('Match: '.$ruleNumber.':'.$ruleCategory.'; '.$bounceType.'; '.$email); |
|
771 | 771 | |
772 | 772 | return true; |
773 | 773 | } else { |
@@ -814,14 +814,14 @@ discard block |
||
814 | 814 | exit(); |
815 | 815 | } |
816 | 816 | |
817 | - $port = $this->port . '/' . $this->service . '/' . $this->serviceOption; |
|
818 | - $mbox = imap_open('{' . $this->mailhost . ':' . $port . '}', $this->mailboxUserName, $this->mailboxPassword, OP_HALFOPEN); |
|
817 | + $port = $this->port.'/'.$this->service.'/'.$this->serviceOption; |
|
818 | + $mbox = imap_open('{'.$this->mailhost.':'.$port.'}', $this->mailboxUserName, $this->mailboxPassword, OP_HALFOPEN); |
|
819 | 819 | |
820 | 820 | if ($mbox === false) { |
821 | 821 | return false; |
822 | 822 | } |
823 | 823 | |
824 | - $list = imap_getmailboxes($mbox, '{' . $this->mailhost . ':' . $port . '}', '*'); |
|
824 | + $list = imap_getmailboxes($mbox, '{'.$this->mailhost.':'.$port.'}', '*'); |
|
825 | 825 | $mailboxFound = false; |
826 | 826 | |
827 | 827 | if (is_array($list)) { |
@@ -836,7 +836,7 @@ discard block |
||
836 | 836 | |
837 | 837 | if (($mailboxFound === false) && $create) { |
838 | 838 | /** @noinspection PhpUsageOfSilenceOperatorInspection */ |
839 | - @imap_createmailbox($mbox, imap_utf7_encode('{' . $this->mailhost . ':' . $port . '}' . $mailbox)); |
|
839 | + @imap_createmailbox($mbox, imap_utf7_encode('{'.$this->mailhost.':'.$port.'}'.$mailbox)); |
|
840 | 840 | imap_close($mbox); |
841 | 841 | |
842 | 842 | return true; |
@@ -493,7 +493,7 @@ discard block |
||
493 | 493 | global $rule_categories, $bmh_newline; |
494 | 494 | if ($result['rule_no'] == '0000') { |
495 | 495 | if ($debug_mode) { |
496 | - echo 'Body:' . $bmh_newline . $body . $bmh_newline; |
|
496 | + echo 'Body:'.$bmh_newline.$body.$bmh_newline; |
|
497 | 497 | echo $bmh_newline; |
498 | 498 | } |
499 | 499 | } else { |
@@ -541,14 +541,14 @@ discard block |
||
541 | 541 | /** @noinspection PhpUsageOfSilenceOperatorInspection */ |
542 | 542 | $email_arr = @imap_rfc822_parse_adrlist($email, 'default.domain.name'); |
543 | 543 | if (isset($email_arr[0]->host) && $email_arr[0]->host != '.SYNTAX-ERROR.' && $email_arr[0]->host != 'default.domain.name') { |
544 | - $result['email'] = $email_arr[0]->mailbox . '@' . $email_arr[0]->host; |
|
544 | + $result['email'] = $email_arr[0]->mailbox.'@'.$email_arr[0]->host; |
|
545 | 545 | } |
546 | 546 | } elseif (preg_match('/Final-Recipient: rfc822;(.*)/i', $dsn_report, $match)) { |
547 | 547 | $email = trim($match[1], "<> \t\r\n\0\x0B"); |
548 | 548 | /** @noinspection PhpUsageOfSilenceOperatorInspection */ |
549 | 549 | $email_arr = @imap_rfc822_parse_adrlist($email, 'default.domain.name'); |
550 | 550 | if (isset($email_arr[0]->host) && $email_arr[0]->host != '.SYNTAX-ERROR.' && $email_arr[0]->host != 'default.domain.name') { |
551 | - $result['email'] = $email_arr[0]->mailbox . '@' . $email_arr[0]->host; |
|
551 | + $result['email'] = $email_arr[0]->mailbox.'@'.$email_arr[0]->host; |
|
552 | 552 | } |
553 | 553 | } |
554 | 554 | |
@@ -1517,7 +1517,7 @@ discard block |
||
1517 | 1517 | * Delivery to the following recipients failed. |
1518 | 1518 | * [email protected] |
1519 | 1519 | */ |
1520 | - elseif (preg_match("/Delivery to the following recipients failed.*\n.*\n.*" . $result['email'] . '/i', $dsn_msg)) { |
|
1520 | + elseif (preg_match("/Delivery to the following recipients failed.*\n.*\n.*".$result['email'].'/i', $dsn_msg)) { |
|
1521 | 1521 | $result['rule_cat'] = 'other'; |
1522 | 1522 | $result['rule_no'] = '0176'; |
1523 | 1523 | } |
@@ -1565,11 +1565,11 @@ discard block |
||
1565 | 1565 | global $rule_categories, $bmh_newline; |
1566 | 1566 | if ($result['rule_no'] == '0000') { |
1567 | 1567 | if ($debug_mode) { |
1568 | - echo 'email: ' . $result['email'] . $bmh_newline; |
|
1569 | - echo 'Action: ' . $action . $bmh_newline; |
|
1570 | - echo 'Status: ' . $status_code . $bmh_newline; |
|
1571 | - echo 'Diagnostic-Code: ' . $diag_code . $bmh_newline; |
|
1572 | - echo "DSN Message:<br />\n" . $dsn_msg . $bmh_newline; |
|
1568 | + echo 'email: '.$result['email'].$bmh_newline; |
|
1569 | + echo 'Action: '.$action.$bmh_newline; |
|
1570 | + echo 'Status: '.$status_code.$bmh_newline; |
|
1571 | + echo 'Diagnostic-Code: '.$diag_code.$bmh_newline; |
|
1572 | + echo "DSN Message:<br />\n".$dsn_msg.$bmh_newline; |
|
1573 | 1573 | echo $bmh_newline; |
1574 | 1574 | } |
1575 | 1575 | } else { |