Completed
Push — 1.10.x ( c135db...ea3352 )
by Julito
26:21
created
main/inc/lib/phpmailer/class.phpmailer.php 1 patch
Spacing   +234 added lines, -235 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
  * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
39 39
  */
40 40
 
41
-if (version_compare(PHP_VERSION, '5.0.0', '<') ) exit("Sorry, this version of PHPMailer will only run on PHP version 5 or greater!\n");
41
+if (version_compare(PHP_VERSION, '5.0.0', '<')) exit("Sorry, this version of PHPMailer will only run on PHP version 5 or greater!\n");
42 42
 
43 43
 class PHPMailer {
44 44
 
@@ -50,64 +50,64 @@  discard block
 block discarded – undo
50 50
    * Email priority (1 = High, 3 = Normal, 5 = low).
51 51
    * @var int
52 52
    */
53
-  public $Priority          = 3;
53
+  public $Priority = 3;
54 54
 
55 55
   /**
56 56
    * Sets the CharSet of the message.
57 57
    * @var string
58 58
    */
59
-  public $CharSet           = 'iso-8859-1';
59
+  public $CharSet = 'iso-8859-1';
60 60
 
61 61
   /**
62 62
    * Sets the Content-type of the message.
63 63
    * @var string
64 64
    */
65
-  public $ContentType       = 'text/plain';
65
+  public $ContentType = 'text/plain';
66 66
 
67 67
   /**
68 68
    * Sets the Encoding of the message. Options for this are
69 69
    *  "8bit", "7bit", "binary", "base64", and "quoted-printable".
70 70
    * @var string
71 71
    */
72
-  public $Encoding          = '8bit';
72
+  public $Encoding = '8bit';
73 73
 
74 74
   /**
75 75
    * Holds the most recent mailer error message.
76 76
    * @var string
77 77
    */
78
-  public $ErrorInfo         = '';
78
+  public $ErrorInfo = '';
79 79
 
80 80
   /**
81 81
    * Sets the From email address for the message.
82 82
    * @var string
83 83
    */
84
-  public $From              = 'root@localhost';
84
+  public $From = 'root@localhost';
85 85
 
86 86
   /**
87 87
    * Sets the From name of the message.
88 88
    * @var string
89 89
    */
90
-  public $FromName          = 'Root User';
90
+  public $FromName = 'Root User';
91 91
 
92 92
   /**
93 93
    * Sets the Sender email (Return-Path) of the message.  If not empty,
94 94
    * will be sent via -f to sendmail or as 'MAIL FROM' in smtp mode.
95 95
    * @var string
96 96
    */
97
-  public $Sender            = '';
97
+  public $Sender = '';
98 98
 
99 99
   /**
100 100
    * Sets the Subject of the message.
101 101
    * @var string
102 102
    */
103
-  public $Subject           = '';
103
+  public $Subject = '';
104 104
 
105 105
   /**
106 106
    * Sets the Body of the message.  This can be either an HTML or text body.
107 107
    * If HTML then run IsHTML(true).
108 108
    * @var string
109 109
    */
110
-  public $Body              = '';
110
+  public $Body = '';
111 111
 
112 112
   /**
113 113
    * Sets the text-only body of the message.  This automatically sets the
@@ -116,39 +116,39 @@  discard block
 block discarded – undo
116 116
    * that can read HTML will view the normal Body.
117 117
    * @var string
118 118
    */
119
-  public $AltBody           = '';
119
+  public $AltBody = '';
120 120
 
121 121
   /**
122 122
    * Sets word wrapping on the body of the message to a given number of
123 123
    * characters.
124 124
    * @var int
125 125
    */
126
-  public $WordWrap          = 0;
126
+  public $WordWrap = 0;
127 127
 
128 128
   /**
129 129
    * Method to send mail: ("mail", "sendmail", or "smtp").
130 130
    * @var string
131 131
    */
132
-  public $Mailer            = 'mail';
132
+  public $Mailer = 'mail';
133 133
 
134 134
   /**
135 135
    * Sets the path of the sendmail program.
136 136
    * @var string
137 137
    */
138
-  public $Sendmail          = '/usr/sbin/sendmail';
138
+  public $Sendmail = '/usr/sbin/sendmail';
139 139
 
140 140
   /**
141 141
    * Path to PHPMailer plugins.  Useful if the SMTP class
142 142
    * is in a different directory than the PHP include path.
143 143
    * @var string
144 144
    */
145
-  public $PluginDir         = '';
145
+  public $PluginDir = '';
146 146
 
147 147
   /**
148 148
    * Sets the email address that a reading confirmation will be sent.
149 149
    * @var string
150 150
    */
151
-  public $ConfirmReadingTo  = '';
151
+  public $ConfirmReadingTo = '';
152 152
 
153 153
   /**
154 154
    * Sets the hostname to use in Message-Id and Received headers
@@ -156,14 +156,14 @@  discard block
 block discarded – undo
156 156
    * by SERVER_NAME is used or 'localhost.localdomain'.
157 157
    * @var string
158 158
    */
159
-  public $Hostname          = '';
159
+  public $Hostname = '';
160 160
 
161 161
   /**
162 162
    * Sets the message ID to be used in the Message-Id header.
163 163
    * If empty, a unique id will be generated.
164 164
    * @var string
165 165
    */
166
-  public $MessageID         = '';
166
+  public $MessageID = '';
167 167
 
168 168
   /////////////////////////////////////////////////
169 169
   // PROPERTIES FOR SMTP
@@ -177,57 +177,57 @@  discard block
 block discarded – undo
177 177
    * Hosts will be tried in order.
178 178
    * @var string
179 179
    */
180
-  public $Host          = 'localhost';
180
+  public $Host = 'localhost';
181 181
 
182 182
   /**
183 183
    * Sets the default SMTP server port.
184 184
    * @var int
185 185
    */
186
-  public $Port          = 25;
186
+  public $Port = 25;
187 187
 
188 188
   /**
189 189
    * Sets the SMTP HELO of the message (Default is $Hostname).
190 190
    * @var string
191 191
    */
192
-  public $Helo          = '';
192
+  public $Helo = '';
193 193
 
194 194
   /**
195 195
    * Sets connection prefix.
196 196
    * Options are "", "ssl" or "tls"
197 197
    * @var string
198 198
    */
199
-  public $SMTPSecure    = '';
199
+  public $SMTPSecure = '';
200 200
 
201 201
   /**
202 202
    * Sets SMTP authentication. Utilizes the Username and Password variables.
203 203
    * @var bool
204 204
    */
205
-  public $SMTPAuth      = false;
205
+  public $SMTPAuth = false;
206 206
 
207 207
   /**
208 208
    * Sets SMTP username.
209 209
    * @var string
210 210
    */
211
-  public $Username      = '';
211
+  public $Username = '';
212 212
 
213 213
   /**
214 214
    * Sets SMTP password.
215 215
    * @var string
216 216
    */
217
-  public $Password      = '';
217
+  public $Password = '';
218 218
 
219 219
   /**
220 220
    * Sets the SMTP server timeout in seconds.
221 221
    * This function will not work with the win32 version.
222 222
    * @var int
223 223
    */
224
-  public $Timeout       = 10;
224
+  public $Timeout = 10;
225 225
 
226 226
   /**
227 227
    * Sets SMTP class debugging on or off.
228 228
    * @var bool
229 229
    */
230
-  public $SMTPDebug     = false;
230
+  public $SMTPDebug = false;
231 231
 
232 232
   /**
233 233
    * Prevents the SMTP connection from being closed after each mail
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
    * emails, instead of sending to entire TO addresses
243 243
    * @var bool
244 244
    */
245
-  public $SingleTo      = false;
245
+  public $SingleTo = false;
246 246
 
247 247
    /**
248 248
    * If SingleTo is true, this provides the array to hold the email addresses
@@ -254,34 +254,34 @@  discard block
 block discarded – undo
254 254
    * Provides the ability to change the line ending
255 255
    * @var string
256 256
    */
257
-  public $LE              = "\n";
257
+  public $LE = "\n";
258 258
 
259 259
   /**
260 260
    * Used with DKIM DNS Resource Record
261 261
    * @var string
262 262
    */
263
-  public $DKIM_selector   = 'phpmailer';
263
+  public $DKIM_selector = 'phpmailer';
264 264
 
265 265
   /**
266 266
    * Used with DKIM DNS Resource Record
267 267
    * optional, in format of email address '[email protected]'
268 268
    * @var string
269 269
    */
270
-  public $DKIM_identity   = '';
270
+  public $DKIM_identity = '';
271 271
 
272 272
   /**
273 273
    * Used with DKIM DNS Resource Record
274 274
    * optional, in format of email address '[email protected]'
275 275
    * @var string
276 276
    */
277
-  public $DKIM_domain     = '';
277
+  public $DKIM_domain = '';
278 278
 
279 279
   /**
280 280
    * Used with DKIM DNS Resource Record
281 281
    * optional, in format of email address '[email protected]'
282 282
    * @var string
283 283
    */
284
-  public $DKIM_private    = '';
284
+  public $DKIM_private = '';
285 285
 
286 286
   /**
287 287
    * Callback Action function name
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
    * Sets the PHPMailer Version number
301 301
    * @var string
302 302
    */
303
-  public $Version         = '5.1';
303
+  public $Version = '5.1';
304 304
 
305 305
   /////////////////////////////////////////////////
306 306
   // PROPERTIES, PRIVATE AND PROTECTED
@@ -451,13 +451,13 @@  discard block
 block discarded – undo
451 451
    */
452 452
   private function AddAnAddress($kind, $address, $name = '') {
453 453
     if (!preg_match('/^(to|cc|bcc|ReplyTo)$/', $kind)) {
454
-      error_log('Invalid recipient array: ' . $kind);
454
+      error_log('Invalid recipient array: '.$kind);
455 455
       return false;
456 456
     }
457 457
     $address = trim($address);
458 458
     $name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim
459 459
     if (!self::ValidateAddress($address)) {
460
-      $this->SetError($this->Lang('invalid_address').': '. $address);
460
+      $this->SetError($this->Lang('invalid_address').': '.$address);
461 461
       if ($this->exceptions) {
462 462
         throw new phpmailerException($this->Lang('invalid_address').': '.$address);
463 463
       }
@@ -485,11 +485,11 @@  discard block
 block discarded – undo
485 485
  * @param string $name
486 486
  * @return boolean
487 487
  */
488
-  public function SetFrom($address, $name = '',$auto=1) {
488
+  public function SetFrom($address, $name = '', $auto = 1) {
489 489
     $address = trim($address);
490 490
     $name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim
491 491
     if (!self::ValidateAddress($address)) {
492
-      $this->SetError($this->Lang('invalid_address').': '. $address);
492
+      $this->SetError($this->Lang('invalid_address').': '.$address);
493 493
       if ($this->exceptions) {
494 494
         throw new phpmailerException($this->Lang('invalid_address').': '.$address);
495 495
       }
@@ -522,7 +522,7 @@  discard block
 block discarded – undo
522 522
    */
523 523
   public static function ValidateAddress($address) {
524 524
     if (function_exists('filter_var')) { //Introduced in PHP 5.2
525
-      if(filter_var($address, FILTER_VALIDATE_EMAIL) === FALSE) {
525
+      if (filter_var($address, FILTER_VALIDATE_EMAIL) === FALSE) {
526 526
         return false;
527 527
       } else {
528 528
         return true;
@@ -549,7 +549,7 @@  discard block
 block discarded – undo
549 549
       }
550 550
 
551 551
       // Set whether the message is multipart/alternative
552
-      if(!empty($this->AltBody)) {
552
+      if (!empty($this->AltBody)) {
553 553
         $this->ContentType = 'multipart/alternative';
554 554
       }
555 555
 
@@ -564,12 +564,12 @@  discard block
 block discarded – undo
564 564
 
565 565
       // digitally sign with DKIM if enabled
566 566
       if ($this->DKIM_domain && $this->DKIM_private) {
567
-        $header_dkim = $this->DKIM_Add($header,$this->Subject,$body);
568
-        $header = str_replace("\r\n","\n",$header_dkim) . $header;
567
+        $header_dkim = $this->DKIM_Add($header, $this->Subject, $body);
568
+        $header = str_replace("\r\n", "\n", $header_dkim).$header;
569 569
       }
570 570
 
571 571
       // Choose the mailer and send through it
572
-      switch($this->Mailer) {
572
+      switch ($this->Mailer) {
573 573
         case 'sendmail':
574 574
           return $this->SendmailSend($header, $body);
575 575
         case 'smtp':
@@ -625,32 +625,32 @@  discard block
 block discarded – undo
625 625
       }
626 626
     if ($this->SingleTo === true) {
627 627
       foreach ($this->SingleToArray as $key => $val) {
628
-        if(!@$mail = popen($sendmail, 'w')) {
629
-          throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
628
+        if (!@$mail = popen($sendmail, 'w')) {
629
+          throw new phpmailerException($this->Lang('execute').$this->Sendmail, self::STOP_CRITICAL);
630 630
         }
631
-        fputs($mail, "To: " . $val . "\n");
631
+        fputs($mail, "To: ".$val."\n");
632 632
         fputs($mail, $header);
633 633
         fputs($mail, $body);
634 634
         $result = pclose($mail);
635 635
         // implement call back function if it exists
636 636
         $isSent = ($result == 0) ? 1 : 0;
637
-        $this->doCallback($isSent,$val,$this->cc,$this->bcc,$this->Subject,$body);
638
-        if($result != 0) {
639
-          throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
637
+        $this->doCallback($isSent, $val, $this->cc, $this->bcc, $this->Subject, $body);
638
+        if ($result != 0) {
639
+          throw new phpmailerException($this->Lang('execute').$this->Sendmail, self::STOP_CRITICAL);
640 640
         }
641 641
       }
642 642
     } else {
643
-      if(!@$mail = popen($sendmail, 'w')) {
644
-        throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
643
+      if (!@$mail = popen($sendmail, 'w')) {
644
+        throw new phpmailerException($this->Lang('execute').$this->Sendmail, self::STOP_CRITICAL);
645 645
       }
646 646
       fputs($mail, $header);
647 647
       fputs($mail, $body);
648 648
       $result = pclose($mail);
649 649
       // implement call back function if it exists
650 650
       $isSent = ($result == 0) ? 1 : 0;
651
-      $this->doCallback($isSent,$this->to,$this->cc,$this->bcc,$this->Subject,$body);
652
-      if($result != 0) {
653
-        throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
651
+      $this->doCallback($isSent, $this->to, $this->cc, $this->bcc, $this->Subject, $body);
652
+      if ($result != 0) {
653
+        throw new phpmailerException($this->Lang('execute').$this->Sendmail, self::STOP_CRITICAL);
654 654
       }
655 655
     }
656 656
     return true;
@@ -665,7 +665,7 @@  discard block
 block discarded – undo
665 665
    */
666 666
   protected function MailSend($header, $body) {
667 667
     $toArr = array();
668
-    foreach($this->to as $t) {
668
+    foreach ($this->to as $t) {
669 669
       $toArr[] = $this->AddrFormat($t);
670 670
     }
671 671
     $to = implode(', ', $toArr);
@@ -679,13 +679,13 @@  discard block
 block discarded – undo
679 679
           $rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
680 680
           // implement call back function if it exists
681 681
           $isSent = ($rt == 1) ? 1 : 0;
682
-          $this->doCallback($isSent,$val,$this->cc,$this->bcc,$this->Subject,$body);
682
+          $this->doCallback($isSent, $val, $this->cc, $this->bcc, $this->Subject, $body);
683 683
         }
684 684
       } else {
685 685
         $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
686 686
         // implement call back function if it exists
687 687
         $isSent = ($rt == 1) ? 1 : 0;
688
-        $this->doCallback($isSent,$to,$this->cc,$this->bcc,$this->Subject,$body);
688
+        $this->doCallback($isSent, $to, $this->cc, $this->bcc, $this->Subject, $body);
689 689
       }
690 690
     } else {
691 691
       if ($this->SingleTo === true && count($toArr) > 1) {
@@ -693,19 +693,19 @@  discard block
 block discarded – undo
693 693
           $rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
694 694
           // implement call back function if it exists
695 695
           $isSent = ($rt == 1) ? 1 : 0;
696
-          $this->doCallback($isSent,$val,$this->cc,$this->bcc,$this->Subject,$body);
696
+          $this->doCallback($isSent, $val, $this->cc, $this->bcc, $this->Subject, $body);
697 697
         }
698 698
       } else {
699 699
         $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header);
700 700
         // implement call back function if it exists
701 701
         $isSent = ($rt == 1) ? 1 : 0;
702
-        $this->doCallback($isSent,$to,$this->cc,$this->bcc,$this->Subject,$body);
702
+        $this->doCallback($isSent, $to, $this->cc, $this->bcc, $this->Subject, $body);
703 703
       }
704 704
     }
705 705
     if (isset($old_from)) {
706 706
       ini_set('sendmail_from', $old_from);
707 707
     }
708
-    if(!$rt) {
708
+    if (!$rt) {
709 709
       throw new phpmailerException($this->Lang('instantiate'), self::STOP_CRITICAL);
710 710
     }
711 711
     return true;
@@ -721,10 +721,10 @@  discard block
 block discarded – undo
721 721
    * @return bool
722 722
    */
723 723
   protected function SmtpSend($header, $body) {
724
-    require_once $this->PluginDir . 'class.smtp.php';
724
+    require_once $this->PluginDir.'class.smtp.php';
725 725
     $bad_rcpt = array();
726 726
 
727
-    if(!$this->SmtpConnect()) {
727
+    if (!$this->SmtpConnect()) {
728 728
       throw new phpmailerException($this->Lang('smtp_connect_failed'), self::STOP_CRITICAL);
729 729
     }
730 730
 
@@ -733,57 +733,57 @@  discard block
 block discarded – undo
733 733
     } else {
734 734
         $smtp_from = $this->From;
735 735
     }
736
-    if(!$this->smtp->Mail($smtp_from)) {
737
-      throw new phpmailerException($this->Lang('from_failed') . $smtp_from, self::STOP_CRITICAL);
736
+    if (!$this->smtp->Mail($smtp_from)) {
737
+      throw new phpmailerException($this->Lang('from_failed').$smtp_from, self::STOP_CRITICAL);
738 738
     }
739 739
 
740 740
     // Attempt to send attach all recipients
741
-    foreach($this->to as $to) {
741
+    foreach ($this->to as $to) {
742 742
       if (!$this->smtp->Recipient($to[0])) {
743 743
         $bad_rcpt[] = $to[0];
744 744
         // implement call back function if it exists
745 745
         $isSent = 0;
746
-        $this->doCallback($isSent,$to[0],'','',$this->Subject,$body);
746
+        $this->doCallback($isSent, $to[0], '', '', $this->Subject, $body);
747 747
       } else {
748 748
         // implement call back function if it exists
749 749
         $isSent = 1;
750
-        $this->doCallback($isSent,$to[0],'','',$this->Subject,$body);
750
+        $this->doCallback($isSent, $to[0], '', '', $this->Subject, $body);
751 751
       }
752 752
     }
753
-    foreach($this->cc as $cc) {
753
+    foreach ($this->cc as $cc) {
754 754
       if (!$this->smtp->Recipient($cc[0])) {
755 755
         $bad_rcpt[] = $cc[0];
756 756
         // implement call back function if it exists
757 757
         $isSent = 0;
758
-        $this->doCallback($isSent,'',$cc[0],'',$this->Subject,$body);
758
+        $this->doCallback($isSent, '', $cc[0], '', $this->Subject, $body);
759 759
       } else {
760 760
         // implement call back function if it exists
761 761
         $isSent = 1;
762
-        $this->doCallback($isSent,'',$cc[0],'',$this->Subject,$body);
762
+        $this->doCallback($isSent, '', $cc[0], '', $this->Subject, $body);
763 763
       }
764 764
     }
765
-    foreach($this->bcc as $bcc) {
765
+    foreach ($this->bcc as $bcc) {
766 766
       if (!$this->smtp->Recipient($bcc[0])) {
767 767
         $bad_rcpt[] = $bcc[0];
768 768
         // implement call back function if it exists
769 769
         $isSent = 0;
770
-        $this->doCallback($isSent,'','',$bcc[0],$this->Subject,$body);
770
+        $this->doCallback($isSent, '', '', $bcc[0], $this->Subject, $body);
771 771
       } else {
772 772
         // implement call back function if it exists
773 773
         $isSent = 1;
774
-        $this->doCallback($isSent,'','',$bcc[0],$this->Subject,$body);
774
+        $this->doCallback($isSent, '', '', $bcc[0], $this->Subject, $body);
775 775
       }
776 776
     }
777 777
 
778 778
 
779
-    if (count($bad_rcpt) > 0 ) { //Create error message for any bad addresses
779
+    if (count($bad_rcpt) > 0) { //Create error message for any bad addresses
780 780
       $badaddresses = implode(', ', $bad_rcpt);
781
-      throw new phpmailerException($this->Lang('recipients_failed') . $badaddresses);
781
+      throw new phpmailerException($this->Lang('recipients_failed').$badaddresses);
782 782
     }
783
-    if(!$this->smtp->Data($header . $body)) {
783
+    if (!$this->smtp->Data($header.$body)) {
784 784
       throw new phpmailerException($this->Lang('data_not_accepted'), self::STOP_CRITICAL);
785 785
     }
786
-    if($this->SMTPKeepAlive == true) {
786
+    if ($this->SMTPKeepAlive == true) {
787 787
       $this->smtp->Reset();
788 788
     }
789 789
     return true;
@@ -797,7 +797,7 @@  discard block
 block discarded – undo
797 797
    * @return bool
798 798
    */
799 799
   public function SmtpConnect() {
800
-    if(is_null($this->smtp)) {
800
+    if (is_null($this->smtp)) {
801 801
       $this->smtp = new SMTP();
802 802
     }
803 803
 
@@ -808,7 +808,7 @@  discard block
 block discarded – undo
808 808
 
809 809
     // Retry while there is no connection
810 810
     try {
811
-      while($index < count($hosts) && !$connection) {
811
+      while ($index < count($hosts) && !$connection) {
812 812
         $hostinfo = array();
813 813
         if (preg_match('/^(.+):([0-9]+)$/', $hosts[$index], $hostinfo)) {
814 814
           $host = $hostinfo[1];
@@ -821,7 +821,7 @@  discard block
 block discarded – undo
821 821
         $tls = ($this->SMTPSecure == 'tls');
822 822
         $ssl = ($this->SMTPSecure == 'ssl');
823 823
 
824
-        if ($this->smtp->Connect(($ssl ? 'ssl://':'').$host, $port, $this->Timeout)) {
824
+        if ($this->smtp->Connect(($ssl ? 'ssl://' : '').$host, $port, $this->Timeout)) {
825 825
 
826 826
           $hello = ($this->Helo != '' ? $this->Helo : $this->ServerHostname());
827 827
           $this->smtp->Hello($hello);
@@ -859,8 +859,8 @@  discard block
 block discarded – undo
859 859
    * @return void
860 860
    */
861 861
   public function SmtpClose() {
862
-    if(!is_null($this->smtp)) {
863
-      if($this->smtp->Connected()) {
862
+    if (!is_null($this->smtp)) {
863
+      if ($this->smtp->Connected()) {
864 864
         $this->smtp->Quit();
865 865
         $this->smtp->Close();
866 866
       }
@@ -922,7 +922,7 @@  discard block
 block discarded – undo
922 922
    * @return string
923 923
    */
924 924
   public function AddrAppend($type, $addr) {
925
-    $addr_str = $type . ': ';
925
+    $addr_str = $type.': ';
926 926
     $addresses = array();
927 927
     foreach ($addr as $a) {
928 928
       $addresses[] = $this->AddrFormat($a);
@@ -942,7 +942,7 @@  discard block
 block discarded – undo
942 942
     if (empty($addr[1])) {
943 943
       return $this->SecureHeader($addr[0]);
944 944
     } else {
945
-      return $this->EncodeHeader($this->SecureHeader($addr[1]), 'phrase') . " <" . $this->SecureHeader($addr[0]) . ">";
945
+      return $this->EncodeHeader($this->SecureHeader($addr[1]), 'phrase')." <".$this->SecureHeader($addr[0]).">";
946 946
     }
947 947
   }
948 948
 
@@ -969,10 +969,10 @@  discard block
 block discarded – undo
969 969
 
970 970
     $line = explode($this->LE, $message);
971 971
     $message = '';
972
-    for ($i=0 ;$i < count($line); $i++) {
972
+    for ($i = 0; $i < count($line); $i++) {
973 973
       $line_part = explode(' ', $line[$i]);
974 974
       $buf = '';
975
-      for ($e = 0; $e<count($line_part); $e++) {
975
+      for ($e = 0; $e < count($line_part); $e++) {
976 976
         $word = $line_part[$e];
977 977
         if ($qp_mode and (strlen($word) > $length)) {
978 978
           $space_left = $length - strlen($buf) - 1;
@@ -988,10 +988,10 @@  discard block
 block discarded – undo
988 988
               }
989 989
               $part = substr($word, 0, $len);
990 990
               $word = substr($word, $len);
991
-              $buf .= ' ' . $part;
992
-              $message .= $buf . sprintf("=%s", $this->LE);
991
+              $buf .= ' '.$part;
992
+              $message .= $buf.sprintf("=%s", $this->LE);
993 993
             } else {
994
-              $message .= $buf . $soft_break;
994
+              $message .= $buf.$soft_break;
995 995
             }
996 996
             $buf = '';
997 997
           }
@@ -1008,22 +1008,22 @@  discard block
 block discarded – undo
1008 1008
             $word = substr($word, $len);
1009 1009
 
1010 1010
             if (strlen($word) > 0) {
1011
-              $message .= $part . sprintf("=%s", $this->LE);
1011
+              $message .= $part.sprintf("=%s", $this->LE);
1012 1012
             } else {
1013 1013
               $buf = $part;
1014 1014
             }
1015 1015
           }
1016 1016
         } else {
1017 1017
           $buf_o = $buf;
1018
-          $buf .= ($e == 0) ? $word : (' ' . $word);
1018
+          $buf .= ($e == 0) ? $word : (' '.$word);
1019 1019
 
1020 1020
           if (strlen($buf) > $length and $buf_o != '') {
1021
-            $message .= $buf_o . $soft_break;
1021
+            $message .= $buf_o.$soft_break;
1022 1022
             $buf = $word;
1023 1023
           }
1024 1024
         }
1025 1025
       }
1026
-      $message .= $buf . $this->LE;
1026
+      $message .= $buf.$this->LE;
1027 1027
     }
1028 1028
 
1029 1029
     return $message;
@@ -1052,8 +1052,7 @@  discard block
 block discarded – undo
1052 1052
         if ($dec < 128) { // Single byte character.
1053 1053
           // If the encoded char was found at pos 0, it will fit
1054 1054
           // otherwise reduce maxLength to start of the encoded char
1055
-          $maxLength = ($encodedCharPos == 0) ? $maxLength :
1056
-          $maxLength - ($lookBack - $encodedCharPos);
1055
+          $maxLength = ($encodedCharPos == 0) ? $maxLength : $maxLength - ($lookBack - $encodedCharPos);
1057 1056
           $foundSplitPos = true;
1058 1057
         } elseif ($dec >= 192) { // First byte of a multi byte character
1059 1058
           // Reduce maxLength to split at start of character
@@ -1077,11 +1076,11 @@  discard block
 block discarded – undo
1077 1076
    * @return void
1078 1077
    */
1079 1078
   public function SetWordWrap() {
1080
-    if($this->WordWrap < 1) {
1079
+    if ($this->WordWrap < 1) {
1081 1080
       return;
1082 1081
     }
1083 1082
 
1084
-    switch($this->message_type) {
1083
+    switch ($this->message_type) {
1085 1084
       case 'alt':
1086 1085
       case 'alt_attachments':
1087 1086
         $this->AltBody = $this->WrapText($this->AltBody, $this->WordWrap);
@@ -1102,24 +1101,24 @@  discard block
 block discarded – undo
1102 1101
 
1103 1102
     // Set the boundaries
1104 1103
     $uniq_id = md5(uniqid(time()));
1105
-    $this->boundary[1] = 'b1_' . $uniq_id;
1106
-    $this->boundary[2] = 'b2_' . $uniq_id;
1104
+    $this->boundary[1] = 'b1_'.$uniq_id;
1105
+    $this->boundary[2] = 'b2_'.$uniq_id;
1107 1106
 
1108 1107
     $result .= $this->HeaderLine('Date', self::RFCDate());
1109
-    if($this->Sender == '') {
1108
+    if ($this->Sender == '') {
1110 1109
       $result .= $this->HeaderLine('Return-Path', trim($this->From));
1111 1110
     } else {
1112 1111
       $result .= $this->HeaderLine('Return-Path', trim($this->Sender));
1113 1112
     }
1114 1113
 
1115 1114
     // To be created automatically by mail()
1116
-    if($this->Mailer != 'mail') {
1115
+    if ($this->Mailer != 'mail') {
1117 1116
       if ($this->SingleTo === true) {
1118
-        foreach($this->to as $t) {
1117
+        foreach ($this->to as $t) {
1119 1118
           $this->SingleToArray[] = $this->AddrFormat($t);
1120 1119
         }
1121 1120
       } else {
1122
-        if(count($this->to) > 0) {
1121
+        if (count($this->to) > 0) {
1123 1122
           $result .= $this->AddrAppend('To', $this->to);
1124 1123
         } elseif (count($this->cc) == 0) {
1125 1124
           $result .= $this->HeaderLine('To', 'undisclosed-recipients:;');
@@ -1133,38 +1132,38 @@  discard block
 block discarded – undo
1133 1132
     $result .= $this->AddrAppend('From', $from);
1134 1133
 
1135 1134
     // sendmail and mail() extract Cc from the header before sending
1136
-    if(count($this->cc) > 0) {
1135
+    if (count($this->cc) > 0) {
1137 1136
       $result .= $this->AddrAppend('Cc', $this->cc);
1138 1137
     }
1139 1138
 
1140 1139
     // sendmail and mail() extract Bcc from the header before sending
1141
-    if((($this->Mailer == 'sendmail') || ($this->Mailer == 'mail')) && (count($this->bcc) > 0)) {
1140
+    if ((($this->Mailer == 'sendmail') || ($this->Mailer == 'mail')) && (count($this->bcc) > 0)) {
1142 1141
       $result .= $this->AddrAppend('Bcc', $this->bcc);
1143 1142
     }
1144 1143
 
1145
-    if(count($this->ReplyTo) > 0) {
1144
+    if (count($this->ReplyTo) > 0) {
1146 1145
       $result .= $this->AddrAppend('Reply-to', $this->ReplyTo);
1147 1146
     }
1148 1147
 
1149 1148
     // mail() sets the subject itself
1150
-    if($this->Mailer != 'mail') {
1149
+    if ($this->Mailer != 'mail') {
1151 1150
       $result .= $this->HeaderLine('Subject', $this->EncodeHeader($this->SecureHeader($this->Subject)));
1152 1151
     }
1153 1152
 
1154
-    if($this->MessageID != '') {
1155
-      $result .= $this->HeaderLine('Message-ID',$this->MessageID);
1153
+    if ($this->MessageID != '') {
1154
+      $result .= $this->HeaderLine('Message-ID', $this->MessageID);
1156 1155
     } else {
1157 1156
       $result .= sprintf("Message-ID: <%s@%s>%s", $uniq_id, $this->ServerHostname(), $this->LE);
1158 1157
     }
1159 1158
     $result .= $this->HeaderLine('X-Priority', $this->Priority);
1160 1159
     $result .= $this->HeaderLine('X-Mailer', 'PHPMailer '.$this->Version.' (phpmailer.sourceforge.net)');
1161 1160
 
1162
-    if($this->ConfirmReadingTo != '') {
1163
-      $result .= $this->HeaderLine('Disposition-Notification-To', '<' . trim($this->ConfirmReadingTo) . '>');
1161
+    if ($this->ConfirmReadingTo != '') {
1162
+      $result .= $this->HeaderLine('Disposition-Notification-To', '<'.trim($this->ConfirmReadingTo).'>');
1164 1163
     }
1165 1164
 
1166 1165
     // Add custom headers
1167
-    for($index = 0; $index < count($this->CustomHeader); $index++) {
1166
+    for ($index = 0; $index < count($this->CustomHeader); $index++) {
1168 1167
       $result .= $this->HeaderLine(trim($this->CustomHeader[$index][0]), $this->EncodeHeader(trim($this->CustomHeader[$index][1])));
1169 1168
     }
1170 1169
     if (!$this->sign_key_file) {
@@ -1182,27 +1181,27 @@  discard block
 block discarded – undo
1182 1181
    */
1183 1182
   public function GetMailMIME() {
1184 1183
     $result = '';
1185
-    switch($this->message_type) {
1184
+    switch ($this->message_type) {
1186 1185
       case 'plain':
1187 1186
         $result .= $this->HeaderLine('Content-Transfer-Encoding', $this->Encoding);
1188 1187
         $result .= sprintf("Content-Type: %s; charset=\"%s\"", $this->ContentType, $this->CharSet);
1189 1188
         break;
1190 1189
       case 'attachments':
1191 1190
       case 'alt_attachments':
1192
-        if($this->InlineImageExists()){
1191
+        if ($this->InlineImageExists()) {
1193 1192
           $result .= sprintf("Content-Type: %s;%s\ttype=\"text/html\";%s\tboundary=\"%s\"%s", 'multipart/related', $this->LE, $this->LE, $this->boundary[1], $this->LE);
1194 1193
         } else {
1195 1194
           $result .= $this->HeaderLine('Content-Type', 'multipart/mixed;');
1196
-          $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"');
1195
+          $result .= $this->TextLine("\tboundary=\"".$this->boundary[1].'"');
1197 1196
         }
1198 1197
         break;
1199 1198
       case 'alt':
1200 1199
         $result .= $this->HeaderLine('Content-Type', 'multipart/alternative;');
1201
-        $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"');
1200
+        $result .= $this->TextLine("\tboundary=\"".$this->boundary[1].'"');
1202 1201
         break;
1203 1202
     }
1204 1203
 
1205
-    if($this->Mailer != 'mail') {
1204
+    if ($this->Mailer != 'mail') {
1206 1205
       $result .= $this->LE.$this->LE;
1207 1206
     }
1208 1207
 
@@ -1223,7 +1222,7 @@  discard block
 block discarded – undo
1223 1222
 
1224 1223
     $this->SetWordWrap();
1225 1224
 
1226
-    switch($this->message_type) {
1225
+    switch ($this->message_type) {
1227 1226
       case 'alt':
1228 1227
         $body .= $this->GetBoundary($this->boundary[1], '', 'text/plain', '');
1229 1228
         $body .= $this->EncodeString($this->AltBody, $this->Encoding);
@@ -1244,11 +1243,11 @@  discard block
 block discarded – undo
1244 1243
         break;
1245 1244
       case 'alt_attachments':
1246 1245
         $body .= sprintf("--%s%s", $this->boundary[1], $this->LE);
1247
-        $body .= sprintf("Content-Type: %s;%s" . "\tboundary=\"%s\"%s", 'multipart/alternative', $this->LE, $this->boundary[2], $this->LE.$this->LE);
1248
-        $body .= $this->GetBoundary($this->boundary[2], '', 'text/plain', '') . $this->LE; // Create text body
1246
+        $body .= sprintf("Content-Type: %s;%s"."\tboundary=\"%s\"%s", 'multipart/alternative', $this->LE, $this->boundary[2], $this->LE.$this->LE);
1247
+        $body .= $this->GetBoundary($this->boundary[2], '', 'text/plain', '').$this->LE; // Create text body
1249 1248
         $body .= $this->EncodeString($this->AltBody, $this->Encoding);
1250 1249
         $body .= $this->LE.$this->LE;
1251
-        $body .= $this->GetBoundary($this->boundary[2], '', 'text/html', '') . $this->LE; // Create the HTML body
1250
+        $body .= $this->GetBoundary($this->boundary[2], '', 'text/html', '').$this->LE; // Create the HTML body
1252 1251
         $body .= $this->EncodeString($this->Body, $this->Encoding);
1253 1252
         $body .= $this->LE.$this->LE;
1254 1253
         $body .= $this->EndBoundary($this->boundary[2]);
@@ -1289,16 +1288,16 @@  discard block
 block discarded – undo
1289 1288
    */
1290 1289
   private function GetBoundary($boundary, $charSet, $contentType, $encoding) {
1291 1290
     $result = '';
1292
-    if($charSet == '') {
1291
+    if ($charSet == '') {
1293 1292
       $charSet = $this->CharSet;
1294 1293
     }
1295
-    if($contentType == '') {
1294
+    if ($contentType == '') {
1296 1295
       $contentType = $this->ContentType;
1297 1296
     }
1298
-    if($encoding == '') {
1297
+    if ($encoding == '') {
1299 1298
       $encoding = $this->Encoding;
1300 1299
     }
1301
-    $result .= $this->TextLine('--' . $boundary);
1300
+    $result .= $this->TextLine('--'.$boundary);
1302 1301
     $result .= sprintf("Content-Type: %s; charset = \"%s\"", $contentType, $charSet);
1303 1302
     $result .= $this->LE;
1304 1303
     $result .= $this->HeaderLine('Content-Transfer-Encoding', $encoding);
@@ -1312,7 +1311,7 @@  discard block
 block discarded – undo
1312 1311
    * @access private
1313 1312
    */
1314 1313
   private function EndBoundary($boundary) {
1315
-    return $this->LE . '--' . $boundary . '--' . $this->LE;
1314
+    return $this->LE.'--'.$boundary.'--'.$this->LE;
1316 1315
   }
1317 1316
 
1318 1317
   /**
@@ -1321,16 +1320,16 @@  discard block
 block discarded – undo
1321 1320
    * @return void
1322 1321
    */
1323 1322
   private function SetMessageType() {
1324
-    if(count($this->attachment) < 1 && strlen($this->AltBody) < 1) {
1323
+    if (count($this->attachment) < 1 && strlen($this->AltBody) < 1) {
1325 1324
       $this->message_type = 'plain';
1326 1325
     } else {
1327
-      if(count($this->attachment) > 0) {
1326
+      if (count($this->attachment) > 0) {
1328 1327
         $this->message_type = 'attachments';
1329 1328
       }
1330
-      if(strlen($this->AltBody) > 0 && count($this->attachment) < 1) {
1329
+      if (strlen($this->AltBody) > 0 && count($this->attachment) < 1) {
1331 1330
         $this->message_type = 'alt';
1332 1331
       }
1333
-      if(strlen($this->AltBody) > 0 && count($this->attachment) > 0) {
1332
+      if (strlen($this->AltBody) > 0 && count($this->attachment) > 0) {
1334 1333
         $this->message_type = 'alt_attachments';
1335 1334
       }
1336 1335
     }
@@ -1342,7 +1341,7 @@  discard block
 block discarded – undo
1342 1341
    * @return string
1343 1342
    */
1344 1343
   public function HeaderLine($name, $value) {
1345
-    return $name . ': ' . $value . $this->LE;
1344
+    return $name.': '.$value.$this->LE;
1346 1345
   }
1347 1346
 
1348 1347
   /**
@@ -1351,7 +1350,7 @@  discard block
 block discarded – undo
1351 1350
    * @return string
1352 1351
    */
1353 1352
   public function TextLine($value) {
1354
-    return $value . $this->LE;
1353
+    return $value.$this->LE;
1355 1354
   }
1356 1355
 
1357 1356
   /////////////////////////////////////////////////
@@ -1370,11 +1369,11 @@  discard block
 block discarded – undo
1370 1369
    */
1371 1370
   public function AddAttachment($path, $name = '', $encoding = 'base64', $type = 'application/octet-stream') {
1372 1371
     try {
1373
-      if ( !@is_file($path) ) {
1374
-        throw new phpmailerException($this->Lang('file_access') . $path, self::STOP_CONTINUE);
1372
+      if (!@is_file($path)) {
1373
+        throw new phpmailerException($this->Lang('file_access').$path, self::STOP_CONTINUE);
1375 1374
       }
1376 1375
       $filename = basename($path);
1377
-      if ( $name == '' ) {
1376
+      if ($name == '') {
1378 1377
         $name = $filename;
1379 1378
       }
1380 1379
 
@@ -1384,7 +1383,7 @@  discard block
 block discarded – undo
1384 1383
         2 => $name,
1385 1384
         3 => $encoding,
1386 1385
         4 => $type,
1387
-        5 => false,  // isStringAttachment
1386
+        5 => false, // isStringAttachment
1388 1387
         6 => 'attachment',
1389 1388
         7 => 0
1390 1389
       );
@@ -1395,7 +1394,7 @@  discard block
 block discarded – undo
1395 1394
         throw $e;
1396 1395
       }
1397 1396
       error_log($e->getMessage()."\n");
1398
-      if ( $e->getCode() == self::STOP_CRITICAL ) {
1397
+      if ($e->getCode() == self::STOP_CRITICAL) {
1399 1398
         return false;
1400 1399
       }
1401 1400
     }
@@ -1440,29 +1439,29 @@  discard block
 block discarded – undo
1440 1439
       $disposition = $attachment[6];
1441 1440
       $cid         = $attachment[7];
1442 1441
       $incl[]      = $attachment[0];
1443
-      if ( $disposition == 'inline' && isset($cidUniq[$cid]) ) { continue; }
1442
+      if ($disposition == 'inline' && isset($cidUniq[$cid])) { continue; }
1444 1443
       $cidUniq[$cid] = true;
1445 1444
 
1446 1445
       $mime[] = sprintf("--%s%s", $this->boundary[1], $this->LE);
1447 1446
       $mime[] = sprintf("Content-Type: %s; name=\"%s\"%s", $type, $this->EncodeHeader($this->SecureHeader($name)), $this->LE);
1448 1447
       $mime[] = sprintf("Content-Transfer-Encoding: %s%s", $encoding, $this->LE);
1449 1448
 
1450
-      if($disposition == 'inline') {
1449
+      if ($disposition == 'inline') {
1451 1450
         $mime[] = sprintf("Content-ID: <%s>%s", $cid, $this->LE);
1452 1451
       }
1453 1452
 
1454 1453
       $mime[] = sprintf("Content-Disposition: %s; filename=\"%s\"%s", $disposition, $this->EncodeHeader($this->SecureHeader($name)), $this->LE.$this->LE);
1455 1454
 
1456 1455
       // Encode as string attachment
1457
-      if($bString) {
1456
+      if ($bString) {
1458 1457
         $mime[] = $this->EncodeString($string, $encoding);
1459
-        if($this->IsError()) {
1458
+        if ($this->IsError()) {
1460 1459
           return '';
1461 1460
         }
1462 1461
         $mime[] = $this->LE.$this->LE;
1463 1462
       } else {
1464 1463
         $mime[] = $this->EncodeFile($path, $encoding);
1465
-        if($this->IsError()) {
1464
+        if ($this->IsError()) {
1466 1465
           return '';
1467 1466
         }
1468 1467
         $mime[] = $this->LE.$this->LE;
@@ -1486,7 +1485,7 @@  discard block
 block discarded – undo
1486 1485
   private function EncodeFile($path, $encoding = 'base64') {
1487 1486
     try {
1488 1487
       if (!is_readable($path)) {
1489
-        throw new phpmailerException($this->Lang('file_open') . $path, self::STOP_CONTINUE);
1488
+        throw new phpmailerException($this->Lang('file_open').$path, self::STOP_CONTINUE);
1490 1489
       }
1491 1490
         $magic_quotes = get_magic_quotes_runtime();
1492 1491
         if ($magic_quotes) {
@@ -1520,9 +1519,9 @@  discard block
 block discarded – undo
1520 1519
    * @access public
1521 1520
    * @return string
1522 1521
    */
1523
-  public function EncodeString ($str, $encoding = 'base64') {
1522
+  public function EncodeString($str, $encoding = 'base64') {
1524 1523
     $encoded = '';
1525
-    switch(strtolower($encoding)) {
1524
+    switch (strtolower($encoding)) {
1526 1525
       case 'base64':
1527 1526
         $encoded = chunk_split(base64_encode($str), 76, $this->LE);
1528 1527
         break;
@@ -1540,7 +1539,7 @@  discard block
 block discarded – undo
1540 1539
         $encoded = $this->EncodeQP($str);
1541 1540
         break;
1542 1541
       default:
1543
-        $this->SetError($this->Lang('encoding') . $encoding);
1542
+        $this->SetError($this->Lang('encoding').$encoding);
1544 1543
         break;
1545 1544
     }
1546 1545
     return $encoded;
@@ -1582,7 +1581,7 @@  discard block
 block discarded – undo
1582 1581
 
1583 1582
     $maxlen = 75 - 7 - strlen($this->CharSet);
1584 1583
     // Try to select the encoding which should produce the shortest output
1585
-    if (strlen($str)/3 < $x) {
1584
+    if (strlen($str) / 3 < $x) {
1586 1585
       $encoding = 'B';
1587 1586
       // Modified by Ivan Tcholakov, 24-JAN-2010.
1588 1587
       //if (function_exists('mb_strlen') && $this->HasMultiBytes($str)) {
@@ -1663,7 +1662,7 @@  discard block
 block discarded – undo
1663 1662
       }
1664 1663
       while (strlen($chunk) > $length);
1665 1664
 
1666
-      $encoded .= $chunk . $this->LE;
1665
+      $encoded .= $chunk.$this->LE;
1667 1666
     }
1668 1667
 
1669 1668
     // Chomp the last linefeed
@@ -1679,37 +1678,37 @@  discard block
 block discarded – undo
1679 1678
   * @param integer $line_max Number of chars allowed on a line before wrapping
1680 1679
   * @return string
1681 1680
   */
1682
-  public function EncodeQPphp( $input = '', $line_max = 76, $space_conv = false) {
1683
-    $hex = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
1681
+  public function EncodeQPphp($input = '', $line_max = 76, $space_conv = false) {
1682
+    $hex = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F');
1684 1683
     $lines = preg_split('/(?:\r\n|\r|\n)/', $input);
1685 1684
     $eol = "\r\n";
1686 1685
     $escape = '=';
1687 1686
     $output = '';
1688
-    while( list(, $line) = each($lines) ) {
1687
+    while (list(, $line) = each($lines)) {
1689 1688
       $linlen = strlen($line);
1690 1689
       $newline = '';
1691
-      for($i = 0; $i < $linlen; $i++) {
1692
-        $c = substr( $line, $i, 1 );
1693
-        $dec = ord( $c );
1694
-        if ( ( $i == 0 ) && ( $dec == 46 ) ) { // convert first point in the line into =2E
1690
+      for ($i = 0; $i < $linlen; $i++) {
1691
+        $c = substr($line, $i, 1);
1692
+        $dec = ord($c);
1693
+        if (($i == 0) && ($dec == 46)) { // convert first point in the line into =2E
1695 1694
           $c = '=2E';
1696 1695
         }
1697
-        if ( $dec == 32 ) {
1698
-          if ( $i == ( $linlen - 1 ) ) { // convert space at eol only
1696
+        if ($dec == 32) {
1697
+          if ($i == ($linlen - 1)) { // convert space at eol only
1699 1698
             $c = '=20';
1700
-          } else if ( $space_conv ) {
1699
+          } else if ($space_conv) {
1701 1700
             $c = '=20';
1702 1701
           }
1703
-        } elseif ( ($dec == 61) || ($dec < 32 ) || ($dec > 126) ) { // always encode "\t", which is *not* required
1704
-          $h2 = floor($dec/16);
1705
-          $h1 = floor($dec%16);
1702
+        } elseif (($dec == 61) || ($dec < 32) || ($dec > 126)) { // always encode "\t", which is *not* required
1703
+          $h2 = floor($dec / 16);
1704
+          $h1 = floor($dec % 16);
1706 1705
           $c = $escape.$hex[$h2].$hex[$h1];
1707 1706
         }
1708
-        if ( (strlen($newline) + strlen($c)) >= $line_max ) { // CRLF is not counted
1707
+        if ((strlen($newline) + strlen($c)) >= $line_max) { // CRLF is not counted
1709 1708
           $output .= $newline.$escape.$eol; //  soft line break; " =\r\n" is okay
1710 1709
           $newline = '';
1711 1710
           // check if newline first character will be point or not
1712
-          if ( $dec == 46 ) {
1711
+          if ($dec == 46) {
1713 1712
             $c = '=2E';
1714 1713
           }
1715 1714
         }
@@ -1761,7 +1760,7 @@  discard block
 block discarded – undo
1761 1760
    * @access public
1762 1761
    * @return string
1763 1762
    */
1764
-  public function EncodeQ ($str, $position = 'text') {
1763
+  public function EncodeQ($str, $position = 'text') {
1765 1764
     // There should not be any EOL in the string
1766 1765
     $encoded = preg_replace('/[\r\n]*/', '', $str);
1767 1766
 
@@ -1804,7 +1803,7 @@  discard block
 block discarded – undo
1804 1803
       2 => basename($filename),
1805 1804
       3 => $encoding,
1806 1805
       4 => $type,
1807
-      5 => true,  // isStringAttachment
1806
+      5 => true, // isStringAttachment
1808 1807
       6 => 'attachment',
1809 1808
       7 => 0
1810 1809
     );
@@ -1825,13 +1824,13 @@  discard block
 block discarded – undo
1825 1824
    */
1826 1825
   public function AddEmbeddedImage($path, $cid, $name = '', $encoding = 'base64', $type = 'application/octet-stream') {
1827 1826
 
1828
-    if ( !@is_file($path) ) {
1829
-      $this->SetError($this->Lang('file_access') . $path);
1827
+    if (!@is_file($path)) {
1828
+      $this->SetError($this->Lang('file_access').$path);
1830 1829
       return false;
1831 1830
     }
1832 1831
 
1833 1832
     $filename = basename($path);
1834
-    if ( $name == '' ) {
1833
+    if ($name == '') {
1835 1834
       $name = $filename;
1836 1835
     }
1837 1836
 
@@ -1842,7 +1841,7 @@  discard block
 block discarded – undo
1842 1841
       2 => $name,
1843 1842
       3 => $encoding,
1844 1843
       4 => $type,
1845
-      5 => false,  // isStringAttachment
1844
+      5 => false, // isStringAttachment
1846 1845
       6 => 'inline',
1847 1846
       7 => $cid
1848 1847
     );
@@ -1856,7 +1855,7 @@  discard block
 block discarded – undo
1856 1855
    * @return bool
1857 1856
    */
1858 1857
   public function InlineImageExists() {
1859
-    foreach($this->attachment as $attachment) {
1858
+    foreach ($this->attachment as $attachment) {
1860 1859
       if ($attachment[6] == 'inline') {
1861 1860
         return true;
1862 1861
       }
@@ -1873,7 +1872,7 @@  discard block
 block discarded – undo
1873 1872
    * @return void
1874 1873
    */
1875 1874
   public function ClearAddresses() {
1876
-    foreach($this->to as $to) {
1875
+    foreach ($this->to as $to) {
1877 1876
       unset($this->all_recipients[strtolower($to[0])]);
1878 1877
     }
1879 1878
     $this->to = array();
@@ -1884,7 +1883,7 @@  discard block
 block discarded – undo
1884 1883
    * @return void
1885 1884
    */
1886 1885
   public function ClearCCs() {
1887
-    foreach($this->cc as $cc) {
1886
+    foreach ($this->cc as $cc) {
1888 1887
       unset($this->all_recipients[strtolower($cc[0])]);
1889 1888
     }
1890 1889
     $this->cc = array();
@@ -1895,7 +1894,7 @@  discard block
 block discarded – undo
1895 1894
    * @return void
1896 1895
    */
1897 1896
   public function ClearBCCs() {
1898
-    foreach($this->bcc as $bcc) {
1897
+    foreach ($this->bcc as $bcc) {
1899 1898
       unset($this->all_recipients[strtolower($bcc[0])]);
1900 1899
     }
1901 1900
     $this->bcc = array();
@@ -1952,7 +1951,7 @@  discard block
 block discarded – undo
1952 1951
     if ($this->Mailer == 'smtp' and !is_null($this->smtp)) {
1953 1952
       $lasterror = $this->smtp->getError();
1954 1953
       if (!empty($lasterror) and array_key_exists('smtp_msg', $lasterror)) {
1955
-        $msg .= '<p>' . $this->Lang('smtp_error') . $lasterror['smtp_msg'] . "</p>\n";
1954
+        $msg .= '<p>'.$this->Lang('smtp_error').$lasterror['smtp_msg']."</p>\n";
1956 1955
       }
1957 1956
     }
1958 1957
     $this->ErrorInfo = $msg;
@@ -1968,7 +1967,7 @@  discard block
 block discarded – undo
1968 1967
     $tz = date('Z');
1969 1968
     $tzs = ($tz < 0) ? '-' : '+';
1970 1969
     $tz = abs($tz);
1971
-    $tz = (int)($tz/3600)*100 + ($tz%3600)/60;
1970
+    $tz = (int) ($tz / 3600) * 100 + ($tz % 3600) / 60;
1972 1971
     $result = sprintf("%s %s%04d", date('D, j M Y H:i:s'), $tzs, $tz);
1973 1972
 
1974 1973
     return $result;
@@ -1997,14 +1996,14 @@  discard block
 block discarded – undo
1997 1996
    * @return string
1998 1997
    */
1999 1998
   private function Lang($key) {
2000
-    if(count($this->language) < 1) {
1999
+    if (count($this->language) < 1) {
2001 2000
       $this->SetLanguage('en'); // set the default language
2002 2001
     }
2003 2002
 
2004
-    if(isset($this->language[$key])) {
2003
+    if (isset($this->language[$key])) {
2005 2004
       return $this->language[$key];
2006 2005
     } else {
2007
-      return 'Language string failed to load: ' . $key;
2006
+      return 'Language string failed to load: '.$key;
2008 2007
     }
2009 2008
   }
2010 2009
 
@@ -2045,19 +2044,19 @@  discard block
 block discarded – undo
2045 2044
    */
2046 2045
   public function MsgHTML($message, $basedir = '') {
2047 2046
     preg_match_all("/(src|background)=\"(.*)\"/Ui", $message, $images);
2048
-    if(isset($images[2])) {
2049
-      foreach($images[2] as $i => $url) {
2047
+    if (isset($images[2])) {
2048
+      foreach ($images[2] as $i => $url) {
2050 2049
         // do not change urls for absolute images (thanks to corvuscorax)
2051
-        if (!preg_match('#^[A-z]+://#',$url)) {
2050
+        if (!preg_match('#^[A-z]+://#', $url)) {
2052 2051
           $filename = basename($url);
2053 2052
           $directory = dirname($url);
2054
-          ($directory == '.')?$directory='':'';
2055
-          $cid = 'cid:' . md5($filename);
2053
+          ($directory == '.') ? $directory = '' : '';
2054
+          $cid = 'cid:'.md5($filename);
2056 2055
           $ext = pathinfo($filename, PATHINFO_EXTENSION);
2057
-          $mimeType  = self::_mime_types($ext);
2058
-          if ( strlen($basedir) > 1 && substr($basedir,-1) != '/') { $basedir .= '/'; }
2059
-          if ( strlen($directory) > 1 && substr($directory,-1) != '/') { $directory .= '/'; }
2060
-          if ( $this->AddEmbeddedImage($basedir.$directory.$filename, md5($filename), $filename, 'base64',$mimeType) ) {
2056
+          $mimeType = self::_mime_types($ext);
2057
+          if (strlen($basedir) > 1 && substr($basedir, -1) != '/') { $basedir .= '/'; }
2058
+          if (strlen($directory) > 1 && substr($directory, -1) != '/') { $directory .= '/'; }
2059
+          if ($this->AddEmbeddedImage($basedir.$directory.$filename, md5($filename), $filename, 'base64', $mimeType)) {
2061 2060
             $message = preg_replace("/".$images[1][$i]."=\"".preg_quote($url, '/')."\"/Ui", $images[1][$i]."=\"".$cid."\"", $message);
2062 2061
           }
2063 2062
         }
@@ -2065,12 +2064,12 @@  discard block
 block discarded – undo
2065 2064
     }
2066 2065
     $this->IsHTML(true);
2067 2066
     $this->Body = $message;
2068
-    $textMsg = trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/s','',$message)));
2067
+    $textMsg = trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/s', '', $message)));
2069 2068
     if (!empty($textMsg) && empty($this->AltBody)) {
2070 2069
       $this->AltBody = html_entity_decode($textMsg);
2071 2070
     }
2072 2071
     if (empty($this->AltBody)) {
2073
-      $this->AltBody = 'To view this email message, open it in a program that understands HTML!' . "\n\n";
2072
+      $this->AltBody = 'To view this email message, open it in a program that understands HTML!'."\n\n";
2074 2073
     }
2075 2074
   }
2076 2075
 
@@ -2188,10 +2187,10 @@  discard block
 block discarded – undo
2188 2187
   */
2189 2188
   public function set($name, $value = '') {
2190 2189
     try {
2191
-      if (isset($this->$name) ) {
2190
+      if (isset($this->$name)) {
2192 2191
         $this->$name = $value;
2193 2192
       } else {
2194
-        throw new phpmailerException($this->Lang('variable_set') . $name, self::STOP_CRITICAL);
2193
+        throw new phpmailerException($this->Lang('variable_set').$name, self::STOP_CRITICAL);
2195 2194
       }
2196 2195
     } catch (Exception $e) {
2197 2196
       $this->SetError($e->getMessage());
@@ -2235,14 +2234,14 @@  discard block
 block discarded – undo
2235 2234
    * @param string $key_pass Password for private key
2236 2235
    */
2237 2236
   public function DKIM_QP($txt) {
2238
-    $tmp="";
2239
-    $line="";
2240
-    for ($i=0;$i<strlen($txt);$i++) {
2241
-      $ord=ord($txt[$i]);
2242
-      if ( ((0x21 <= $ord) && ($ord <= 0x3A)) || $ord == 0x3C || ((0x3E <= $ord) && ($ord <= 0x7E)) ) {
2243
-        $line.=$txt[$i];
2237
+    $tmp = "";
2238
+    $line = "";
2239
+    for ($i = 0; $i < strlen($txt); $i++) {
2240
+      $ord = ord($txt[$i]);
2241
+      if (((0x21 <= $ord) && ($ord <= 0x3A)) || $ord == 0x3C || ((0x3E <= $ord) && ($ord <= 0x7E))) {
2242
+        $line .= $txt[$i];
2244 2243
       } else {
2245
-        $line.="=".sprintf("%02X",$ord);
2244
+        $line .= "=".sprintf("%02X", $ord);
2246 2245
       }
2247 2246
     }
2248 2247
     return $line;
@@ -2256,8 +2255,8 @@  discard block
 block discarded – undo
2256 2255
    */
2257 2256
   public function DKIM_Sign($s) {
2258 2257
     $privKeyStr = file_get_contents($this->DKIM_private);
2259
-    if ($this->DKIM_passphrase!='') {
2260
-      $privKey = openssl_pkey_get_private($privKeyStr,$this->DKIM_passphrase);
2258
+    if ($this->DKIM_passphrase != '') {
2259
+      $privKey = openssl_pkey_get_private($privKeyStr, $this->DKIM_passphrase);
2261 2260
     } else {
2262 2261
       $privKey = $privKeyStr;
2263 2262
     }
@@ -2273,15 +2272,15 @@  discard block
 block discarded – undo
2273 2272
    * @param string $s Header
2274 2273
    */
2275 2274
   public function DKIM_HeaderC($s) {
2276
-    $s=preg_replace("/\r\n\s+/"," ",$s);
2277
-    $lines=explode("\r\n",$s);
2275
+    $s = preg_replace("/\r\n\s+/", " ", $s);
2276
+    $lines = explode("\r\n", $s);
2278 2277
     foreach ($lines as $key=>$line) {
2279
-      list($heading,$value)=explode(":",$line,2);
2280
-      $heading=strtolower($heading);
2281
-      $value=preg_replace("/\s+/"," ",$value) ; // Compress useless spaces
2282
-      $lines[$key]=$heading.":".trim($value) ; // Don't forget to remove WSP around the value
2278
+      list($heading, $value) = explode(":", $line, 2);
2279
+      $heading = strtolower($heading);
2280
+      $value = preg_replace("/\s+/", " ", $value); // Compress useless spaces
2281
+      $lines[$key] = $heading.":".trim($value); // Don't forget to remove WSP around the value
2283 2282
     }
2284
-    $s=implode("\r\n",$lines);
2283
+    $s = implode("\r\n", $lines);
2285 2284
     return $s;
2286 2285
   }
2287 2286
 
@@ -2294,11 +2293,11 @@  discard block
 block discarded – undo
2294 2293
   public function DKIM_BodyC($body) {
2295 2294
     if ($body == '') return "\r\n";
2296 2295
     // stabilize line endings
2297
-    $body=str_replace("\r\n","\n",$body);
2298
-    $body=str_replace("\n","\r\n",$body);
2296
+    $body = str_replace("\r\n", "\n", $body);
2297
+    $body = str_replace("\n", "\r\n", $body);
2299 2298
     // END stabilize line endings
2300
-    while (substr($body,strlen($body)-4,4) == "\r\n\r\n") {
2301
-      $body=substr($body,0,strlen($body)-2);
2299
+    while (substr($body, strlen($body) - 4, 4) == "\r\n\r\n") {
2300
+      $body = substr($body, 0, strlen($body) - 2);
2302 2301
     }
2303 2302
     return $body;
2304 2303
   }
@@ -2311,52 +2310,52 @@  discard block
 block discarded – undo
2311 2310
    * @param string $subject Subject
2312 2311
    * @param string $body Body
2313 2312
    */
2314
-  public function DKIM_Add($headers_line,$subject,$body) {
2313
+  public function DKIM_Add($headers_line, $subject, $body) {
2315 2314
     $DKIMsignatureType    = 'rsa-sha1'; // Signature & hash algorithms
2316 2315
     $DKIMcanonicalization = 'relaxed/simple'; // Canonicalization of header/body
2317 2316
     $DKIMquery            = 'dns/txt'; // Query method
2318
-    $DKIMtime             = time() ; // Signature Timestamp = seconds since 00:00:00 - Jan 1, 1970 (UTC time zone)
2317
+    $DKIMtime             = time(); // Signature Timestamp = seconds since 00:00:00 - Jan 1, 1970 (UTC time zone)
2319 2318
     $subject_header       = "Subject: $subject";
2320
-    $headers              = explode("\r\n",$headers_line);
2321
-    foreach($headers as $header) {
2322
-      if (strpos($header,'From:') === 0) {
2323
-        $from_header=$header;
2324
-      } elseif (strpos($header,'To:') === 0) {
2325
-        $to_header=$header;
2319
+    $headers              = explode("\r\n", $headers_line);
2320
+    foreach ($headers as $header) {
2321
+      if (strpos($header, 'From:') === 0) {
2322
+        $from_header = $header;
2323
+      } elseif (strpos($header, 'To:') === 0) {
2324
+        $to_header = $header;
2326 2325
       }
2327 2326
     }
2328
-    $from     = str_replace('|','=7C',$this->DKIM_QP($from_header));
2329
-    $to       = str_replace('|','=7C',$this->DKIM_QP($to_header));
2330
-    $subject  = str_replace('|','=7C',$this->DKIM_QP($subject_header)) ; // Copied header fields (dkim-quoted-printable
2327
+    $from     = str_replace('|', '=7C', $this->DKIM_QP($from_header));
2328
+    $to       = str_replace('|', '=7C', $this->DKIM_QP($to_header));
2329
+    $subject  = str_replace('|', '=7C', $this->DKIM_QP($subject_header)); // Copied header fields (dkim-quoted-printable
2331 2330
     $body     = $this->DKIM_BodyC($body);
2332
-    $DKIMlen  = strlen($body) ; // Length of body
2333
-    $DKIMb64  = base64_encode(pack("H*", sha1($body))) ; // Base64 of packed binary SHA-1 hash of body
2334
-    $ident    = ($this->DKIM_identity == '')? '' : " i=" . $this->DKIM_identity . ";";
2335
-    $dkimhdrs = "DKIM-Signature: v=1; a=" . $DKIMsignatureType . "; q=" . $DKIMquery . "; l=" . $DKIMlen . "; s=" . $this->DKIM_selector . ";\r\n".
2336
-                "\tt=" . $DKIMtime . "; c=" . $DKIMcanonicalization . ";\r\n".
2331
+    $DKIMlen  = strlen($body); // Length of body
2332
+    $DKIMb64  = base64_encode(pack("H*", sha1($body))); // Base64 of packed binary SHA-1 hash of body
2333
+    $ident    = ($this->DKIM_identity == '') ? '' : " i=".$this->DKIM_identity.";";
2334
+    $dkimhdrs = "DKIM-Signature: v=1; a=".$DKIMsignatureType."; q=".$DKIMquery."; l=".$DKIMlen."; s=".$this->DKIM_selector.";\r\n".
2335
+                "\tt=".$DKIMtime."; c=".$DKIMcanonicalization.";\r\n".
2337 2336
                 "\th=From:To:Subject;\r\n".
2338
-                "\td=" . $this->DKIM_domain . ";" . $ident . "\r\n".
2337
+                "\td=".$this->DKIM_domain.";".$ident."\r\n".
2339 2338
                 "\tz=$from\r\n".
2340 2339
                 "\t|$to\r\n".
2341 2340
                 "\t|$subject;\r\n".
2342
-                "\tbh=" . $DKIMb64 . ";\r\n".
2341
+                "\tbh=".$DKIMb64.";\r\n".
2343 2342
                 "\tb=";
2344
-    $toSign   = $this->DKIM_HeaderC($from_header . "\r\n" . $to_header . "\r\n" . $subject_header . "\r\n" . $dkimhdrs);
2343
+    $toSign   = $this->DKIM_HeaderC($from_header."\r\n".$to_header."\r\n".$subject_header."\r\n".$dkimhdrs);
2345 2344
     $signed   = $this->DKIM_Sign($toSign);
2346 2345
     return "X-PHPMAILER-DKIM: phpmailer.worxware.com\r\n".$dkimhdrs.$signed."\r\n";
2347 2346
   }
2348 2347
 
2349
-  protected function doCallback($isSent,$to,$cc,$bcc,$subject,$body) {
2348
+  protected function doCallback($isSent, $to, $cc, $bcc, $subject, $body) {
2350 2349
     if (!empty($this->action_function) && function_exists($this->action_function)) {
2351
-      $params = array($isSent,$to,$cc,$bcc,$subject,$body);
2352
-      call_user_func_array($this->action_function,$params);
2350
+      $params = array($isSent, $to, $cc, $bcc, $subject, $body);
2351
+      call_user_func_array($this->action_function, $params);
2353 2352
     }
2354 2353
   }
2355 2354
 }
2356 2355
 
2357 2356
 class phpmailerException extends Exception {
2358 2357
   public function errorMessage() {
2359
-    $errorMsg = '<strong>' . $this->getMessage() . "</strong><br />\n";
2358
+    $errorMsg = '<strong>'.$this->getMessage()."</strong><br />\n";
2360 2359
     return $errorMsg;
2361 2360
   }
2362 2361
 }
Please login to merge, or discard this patch.