Completed
Push — master ( fb77ca...1ca570 )
by Lars
02:07
created
src/BounceMailHandler/BounceMailHandler.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
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
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
   {
310 310
     // before starting the processing, let's check the delete flag and do global deletes if true
311 311
     if (trim($this->deleteMsgDate) != '') {
312
-      echo 'processing global delete based on date of ' . $this->deleteMsgDate . '<br />';
312
+      echo 'processing global delete based on date of '.$this->deleteMsgDate.'<br />';
313 313
       $this->globalDelete();
314 314
     }
315 315
 
@@ -319,23 +319,23 @@  discard block
 block discarded – undo
319 319
       $this->moveHard = false;
320 320
     }
321 321
 
322
-    $port = $this->port . '/' . $this->service . '/' . $this->serviceOption;
322
+    $port = $this->port.'/'.$this->service.'/'.$this->serviceOption;
323 323
 
324 324
     set_time_limit(6000);
325 325
 
326 326
     if (!$this->testMode) {
327
-      $this->mailboxLink = imap_open('{' . $this->mailhost . ':' . $port . '}' . $this->boxname, $this->mailboxUserName, $this->mailboxPassword, CL_EXPUNGE | ($this->testMode ? OP_READONLY : 0));
327
+      $this->mailboxLink = imap_open('{'.$this->mailhost.':'.$port.'}'.$this->boxname, $this->mailboxUserName, $this->mailboxPassword, CL_EXPUNGE | ($this->testMode ? OP_READONLY : 0));
328 328
     } else {
329
-      $this->mailboxLink = imap_open('{' . $this->mailhost . ':' . $port . '}' . $this->boxname, $this->mailboxUserName, $this->mailboxPassword, ($this->testMode ? OP_READONLY : 0));
329
+      $this->mailboxLink = imap_open('{'.$this->mailhost.':'.$port.'}'.$this->boxname, $this->mailboxUserName, $this->mailboxPassword, ($this->testMode ? OP_READONLY : 0));
330 330
     }
331 331
 
332 332
     if (!$this->mailboxLink) {
333
-      $this->errorMessage = 'Cannot create ' . $this->service . ' connection to ' . $this->mailhost . $this->bmhNewLine . 'Error MSG: ' . imap_last_error();
333
+      $this->errorMessage = 'Cannot create '.$this->service.' connection to '.$this->mailhost.$this->bmhNewLine.'Error MSG: '.imap_last_error();
334 334
       $this->output();
335 335
 
336 336
       return false;
337 337
     } else {
338
-      $this->output('Connected to: ' . $this->mailhost . ' (' . $this->mailboxUserName . ')');
338
+      $this->output('Connected to: '.$this->mailhost.' ('.$this->mailboxUserName.')');
339 339
 
340 340
       return true;
341 341
     }
@@ -351,14 +351,14 @@  discard block
 block discarded – undo
351 351
     $dateArr = explode('-', $this->deleteMsgDate); // date format is yyyy-mm-dd
352 352
     $delDate = mktime(0, 0, 0, $dateArr[1], $dateArr[2], $dateArr[0]);
353 353
 
354
-    $port = $this->port . '/' . $this->service . '/' . $this->serviceOption;
355
-    $mboxt = imap_open('{' . $this->mailhost . ':' . $port . '}', $this->mailboxUserName, $this->mailboxPassword, OP_HALFOPEN);
354
+    $port = $this->port.'/'.$this->service.'/'.$this->serviceOption;
355
+    $mboxt = imap_open('{'.$this->mailhost.':'.$port.'}', $this->mailboxUserName, $this->mailboxPassword, OP_HALFOPEN);
356 356
 
357 357
     if ($mboxt === false) {
358 358
       return false;
359 359
     }
360 360
 
361
-    $list = imap_getmailboxes($mboxt, '{' . $this->mailhost . ':' . $port . '}', '*');
361
+    $list = imap_getmailboxes($mboxt, '{'.$this->mailhost.':'.$port.'}', '*');
362 362
 
363 363
     if (is_array($list)) {
364 364
       foreach ($list as $key => $val) {
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
         $nameRaw = $nameArr[count($nameArr) - 1];
368 368
 
369 369
         if (false === stripos($nameRaw, 'sent')) {
370
-          $mboxd = imap_open('{' . $this->mailhost . ':' . $port . '}' . $nameRaw, $this->mailboxUserName, $this->mailboxPassword, CL_EXPUNGE);
370
+          $mboxd = imap_open('{'.$this->mailhost.':'.$port.'}'.$nameRaw, $this->mailboxUserName, $this->mailboxPassword, CL_EXPUNGE);
371 371
           $messages = imap_sort($mboxd, SORTDATE, 0);
372 372
           $i = 0;
373 373
 
@@ -407,9 +407,9 @@  discard block
 block discarded – undo
407 407
   {
408 408
     if ($this->verbose >= $verboseLevel) {
409 409
       if (empty($msg)) {
410
-        echo $this->errorMessage . $this->bmhNewLine;
410
+        echo $this->errorMessage.$this->bmhNewLine;
411 411
       } else {
412
-        echo $msg . $this->bmhNewLine;
412
+        echo $msg.$this->bmhNewLine;
413 413
       }
414 414
     }
415 415
   }
@@ -432,12 +432,12 @@  discard block
 block discarded – undo
432 432
     }
433 433
 
434 434
     if (!$this->mailboxLink) {
435
-      $this->errorMessage = 'Cannot open the mailbox file to ' . $filePath . $this->bmhNewLine . 'Error MSG: ' . imap_last_error();
435
+      $this->errorMessage = 'Cannot open the mailbox file to '.$filePath.$this->bmhNewLine.'Error MSG: '.imap_last_error();
436 436
       $this->output();
437 437
 
438 438
       return false;
439 439
     } else {
440
-      $this->output('Opened ' . $filePath);
440
+      $this->output('Opened '.$filePath);
441 441
 
442 442
       return true;
443 443
     }
@@ -475,12 +475,12 @@  discard block
 block discarded – undo
475 475
     $unprocessedCount = 0;
476 476
     $deletedCount = 0;
477 477
     $movedCount = 0;
478
-    $this->output('Total: ' . $totalCount . ' messages ');
478
+    $this->output('Total: '.$totalCount.' messages ');
479 479
 
480 480
     // process maximum number of messages
481 481
     if ($fetchedCount > $this->maxMessages) {
482 482
       $fetchedCount = $this->maxMessages;
483
-      $this->output('Processing first ' . $fetchedCount . ' messages ');
483
+      $this->output('Processing first '.$fetchedCount.' messages ');
484 484
     }
485 485
 
486 486
     if ($this->testMode) {
@@ -517,7 +517,7 @@  discard block
 block discarded – undo
517 517
           $processed = $this->processBounce($x, 'DSN', $totalCount);
518 518
         } else {
519 519
           // not standard DSN msg
520
-          $this->output('Msg #' . $x . ' is not a standard DSN message', self::VERBOSE_REPORT);
520
+          $this->output('Msg #'.$x.' is not a standard DSN message', self::VERBOSE_REPORT);
521 521
 
522 522
           if ($this->debugBodyRule) {
523 523
             if ($structure->ifdescription) {
@@ -543,7 +543,7 @@  discard block
 block discarded – undo
543 543
             $processed = $this->processBounce($x, 'DSN', $totalCount);
544 544
           } else {
545 545
             // not standard DSN msg
546
-            $this->output('Msg #' . $x . ' is not a standard DSN message', self::VERBOSE_REPORT);
546
+            $this->output('Msg #'.$x.' is not a standard DSN message', self::VERBOSE_REPORT);
547 547
 
548 548
             if ($this->debugBodyRule) {
549 549
               $this->output("  Content-Type : {$match[1]}", self::VERBOSE_DEBUG);
@@ -553,10 +553,10 @@  discard block
 block discarded – undo
553 553
           }
554 554
         } else {
555 555
           // didn't get content-type header
556
-          $this->output('Msg #' . $x . ' is not a well-formatted MIME mail, missing Content-Type', self::VERBOSE_REPORT);
556
+          $this->output('Msg #'.$x.' is not a well-formatted MIME mail, missing Content-Type', self::VERBOSE_REPORT);
557 557
 
558 558
           if ($this->debugBodyRule) {
559
-            $this->output('  Headers: ' . $this->bmhNewLine . $header . $this->bmhNewLine, self::VERBOSE_DEBUG);
559
+            $this->output('  Headers: '.$this->bmhNewLine.$header.$this->bmhNewLine, self::VERBOSE_DEBUG);
560 560
           }
561 561
 
562 562
           $processed = $this->processBounce($x, 'BODY', $totalCount);
@@ -632,17 +632,17 @@  discard block
 block discarded – undo
632 632
       flush();
633 633
     }
634 634
 
635
-    $this->output($this->bmhNewLine . 'Closing mailbox, and purging messages');
635
+    $this->output($this->bmhNewLine.'Closing mailbox, and purging messages');
636 636
 
637 637
     /** @noinspection PhpUsageOfSilenceOperatorInspection */
638 638
     @imap_expunge($this->mailboxLink);
639 639
     imap_close($this->mailboxLink);
640 640
 
641
-    $this->output('Read: ' . $fetchedCount . ' messages');
642
-    $this->output($processedCount . ' action taken');
643
-    $this->output($unprocessedCount . ' no action taken');
644
-    $this->output($deletedCount . ' messages deleted');
645
-    $this->output($movedCount . ' messages moved');
641
+    $this->output('Read: '.$fetchedCount.' messages');
642
+    $this->output($processedCount.' action taken');
643
+    $this->output($unprocessedCount.' no action taken');
644
+    $this->output($deletedCount.' messages deleted');
645
+    $this->output($movedCount.' messages moved');
646 646
 
647 647
     return true;
648 648
   }
@@ -745,7 +745,7 @@  discard block
 block discarded – undo
745 745
           break;
746 746
 
747 747
         default: // unsupport Content-type
748
-          $this->output('Msg #' . $pos . ' is unsupported Content-Type:' . $structure->type, self::VERBOSE_REPORT);
748
+          $this->output('Msg #'.$pos.' is unsupported Content-Type:'.$structure->type, self::VERBOSE_REPORT);
749 749
 
750 750
           return false;
751 751
       }
@@ -792,7 +792,7 @@  discard block
 block discarded – undo
792 792
       }
793 793
 
794 794
       if ($this->testMode) {
795
-        $this->output('Match: ' . $ruleNumber . ':' . $ruleCategory . '; ' . $bounceType . '; ' . $email);
795
+        $this->output('Match: '.$ruleNumber.':'.$ruleCategory.'; '.$bounceType.'; '.$email);
796 796
       } else {
797 797
         // code below will use the Callback function, but return no value
798 798
         $params = array(
@@ -817,7 +817,7 @@  discard block
 block discarded – undo
817 817
     } else {
818 818
       // match rule, do bounce action
819 819
       if ($this->testMode) {
820
-        $this->output('Match: ' . $ruleNumber . ':' . $ruleCategory . '; ' . $bounceType . '; ' . $email);
820
+        $this->output('Match: '.$ruleNumber.':'.$ruleCategory.'; '.$bounceType.'; '.$email);
821 821
 
822 822
         return true;
823 823
       } else {
@@ -859,19 +859,19 @@  discard block
 block discarded – undo
859 859
     if (trim($mailbox) == '') {
860 860
       // this is a critical error with either the mailbox name blank or an invalid mailbox name
861 861
       // need to stop processing and exit at this point
862
-      echo 'Invalid mailbox name for move operation. Cannot continue: ' . $mailbox . "<br />\n";
862
+      echo 'Invalid mailbox name for move operation. Cannot continue: '.$mailbox."<br />\n";
863 863
       exit();
864 864
     }
865 865
 
866
-    $port = $this->port . '/' . $this->service . '/' . $this->serviceOption;
866
+    $port = $this->port.'/'.$this->service.'/'.$this->serviceOption;
867 867
     /** @noinspection PhpUsageOfSilenceOperatorInspection */
868
-    $mbox = @imap_open('{' . $this->mailhost . ':' . $port . '}', $this->mailboxUserName, $this->mailboxPassword, OP_HALFOPEN);
868
+    $mbox = @imap_open('{'.$this->mailhost.':'.$port.'}', $this->mailboxUserName, $this->mailboxPassword, OP_HALFOPEN);
869 869
 
870 870
     if ($mbox === false) {
871 871
       return false;
872 872
     }
873 873
 
874
-    $list = imap_getmailboxes($mbox, '{' . $this->mailhost . ':' . $port . '}', '*');
874
+    $list = imap_getmailboxes($mbox, '{'.$this->mailhost.':'.$port.'}', '*');
875 875
     $mailboxFound = false;
876 876
 
877 877
     if (is_array($list)) {
@@ -886,7 +886,7 @@  discard block
 block discarded – undo
886 886
 
887 887
       if (($mailboxFound === false) && $create) {
888 888
         /** @noinspection PhpUsageOfSilenceOperatorInspection */
889
-        @imap_createmailbox($mbox, imap_utf7_encode('{' . $this->mailhost . ':' . $port . '}' . $mailbox));
889
+        @imap_createmailbox($mbox, imap_utf7_encode('{'.$this->mailhost.':'.$port.'}'.$mailbox));
890 890
         imap_close($mbox);
891 891
 
892 892
         return true;
Please login to merge, or discard this patch.