Ticket #21074: 21074-phpmailer-5.2.2-rc1-r22121.patch
File 21074-phpmailer-5.2.2-rc1-r22121.patch, 64.9 KB (added by , 11 years ago) |
---|
-
wp-includes/class-phpmailer.php
diff --git wp-includes/class-phpmailer.php wp-includes/class-phpmailer.php index df533c2..fee5e34 100644
2 2 /*~ class.phpmailer.php 3 3 .---------------------------------------------------------------------------. 4 4 | Software: PHPMailer - PHP email class | 5 | Version: 5.2. 1|5 | Version: 5.2.2 | 6 6 | Site: https://code.google.com/a/apache-extras.org/p/phpmailer/ | 7 7 | ------------------------------------------------------------------------- | 8 8 | Admin: Jim Jagielski (project admininistrator) | … … 31 31 * @author Jim Jagielski 32 32 * @copyright 2010 - 2012 Jim Jagielski 33 33 * @copyright 2004 - 2009 Andy Prevost 34 * @version $Id: class.phpmailer.php 450 2010-06-23 16:46:33Z coolbru $35 34 * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License 36 35 */ 37 36 37 38 38 if (version_compare(PHP_VERSION, '5.0.0', '<') ) exit("Sorry, this version of PHPMailer will only run on PHP version 5 or greater!\n"); 39 39 40 /** 41 * Main PHPMailer class definition 42 */ 40 43 class PHPMailer { 41 44 42 45 ///////////////////////////////////////////////// … … class PHPMailer { 87 90 public $FromName = 'Root User'; 88 91 89 92 /** 90 * Sets the Sender email (Return-Path)of the message. If not empty,93 * Sets the Sender email of the message. If not empty, 91 94 * will be sent via -f to sendmail or as 'MAIL FROM' in smtp mode. 95 * If not empty, and ReturnPath is empty, will also be the 96 * Return-Path header. 92 97 * @var string 93 98 */ 94 99 public $Sender = ''; 95 100 96 101 /** 102 * Sets the Return-Path of the message. If empty, it will 103 * be set to either From or Sender. 104 * @var string 105 */ 106 public $ReturnPath = ''; 107 108 /** 97 109 * Sets the Subject of the message. 98 110 * @var string 99 111 */ … … class PHPMailer { 130 142 protected $MIMEHeader = ''; 131 143 132 144 /** 133 * Stores the complete sent MIME message (Body and Headers)145 * Stores the extra header list which CreateHeader() doesn't fold in 134 146 * @var string 135 147 * @access protected 136 148 */ 137 protected $ SentMIMEMessage= '';149 protected $mailHeader = ''; 138 150 139 151 /** 140 152 * Sets word wrapping on the body of the message to a given number of … … class PHPMailer { 156 168 public $Sendmail = '/usr/sbin/sendmail'; 157 169 158 170 /** 171 * Determine if mail() uses a fully sendmail compatible MTA that 172 * supports sendmail's "-oi -f" options 173 * @var boolean 174 */ 175 public $UseSendmailOptions = true; 176 177 /** 159 178 * Path to PHPMailer plugins. Useful if the SMTP class 160 179 * is in a different directory than the PHP include path. 161 180 * @var string … … class PHPMailer { 188 207 ///////////////////////////////////////////////// 189 208 190 209 /** 191 * Sets the SMTP hosts. All hosts must be separated by a 210 * Sets the SMTP hosts. 211 * 212 * All hosts must be separated by a 192 213 * semicolon. You can also specify a different port 193 214 * for each host by using this format: [hostname:port] 194 215 * (e.g. "smtp1.example.com:25;smtp2.example.com"). … … class PHPMailer { 210 231 public $Helo = ''; 211 232 212 233 /** 213 * Sets connection prefix. 214 * Options are "", "ssl" or "tls" 234 * Sets connection prefix. Options are "", "ssl" or "tls" 215 235 * @var string 216 236 */ 217 237 public $SMTPSecure = ''; … … class PHPMailer { 235 255 public $Password = ''; 236 256 237 257 /** 238 * Sets the SMTP server timeout in seconds. 258 * Sets SMTP auth type. Options are LOGIN | PLAIN | NTLM (default LOGIN) 259 * @var string 260 */ 261 public $AuthType = ''; 262 263 /** 264 * Sets SMTP realm. 265 * @var string 266 */ 267 public $Realm = ''; 268 269 /** 270 * Sets SMTP workstation. 271 * @var string 272 */ 273 public $Workstation = ''; 274 275 /** 276 * Sets the SMTP server in seconds. 239 277 * This function will not work with the win32 version. 240 278 * @var int 241 279 */ … … class PHPMailer { 248 286 public $SMTPDebug = false; 249 287 250 288 /** 289 * Sets the function/method to use for debugging output. 290 * Right now we only honor "echo" or "error_log" 291 * @var string 292 */ 293 public $Debugoutput = "echo"; 294 295 /** 251 296 * Prevents the SMTP connection from being closed after each mail 252 297 * sending. If this is set to true then to close the connection 253 298 * requires an explicit call to SmtpClose(). … … class PHPMailer { 269 314 public $SingleToArray = array(); 270 315 271 316 /** 272 * Provides the ability to change the line ending 317 * Provides the ability to change the generic line ending 318 * NOTE: The default remains '\n'. We force CRLF where we KNOW 319 * it must be used via self::CRLF 273 320 * @var string 274 321 */ 275 322 public $LE = "\n"; 276 323 277 /** 278 * Used with DKIM DNS Resource Record 324 /** 325 * Used with DKIM Signing 326 * required parameter if DKIM is enabled 327 * 328 * domain selector example domainkey 279 329 * @var string 280 330 */ 281 public $DKIM_selector = ' phpmailer';331 public $DKIM_selector = ''; 282 332 283 333 /** 284 * Used with DKIM DNS Resource Record285 * optional, in format of email address 'you@yourdomain.com'334 * Used with DKIM Signing 335 * required if DKIM is enabled, in format of email address 'you@yourdomain.com' typically used as the source of the email 286 336 * @var string 287 337 */ 288 338 public $DKIM_identity = ''; 289 339 290 340 /** 291 * Used with DKIM DNS Resource Record 341 * Used with DKIM Signing 342 * optional parameter if your private key requires a passphras 292 343 * @var string 293 344 */ 294 345 public $DKIM_passphrase = ''; 295 346 296 347 /** 297 * Used with DKIM DNS Resource Record298 * optional, in format of email address 'you@yourdomain.com'348 * Used with DKIM Singing 349 * required if DKIM is enabled, in format of email address 'domain.com' 299 350 * @var string 300 351 */ 301 352 public $DKIM_domain = ''; 302 353 303 354 /** 304 * Used with DKIM DNS Resource Record305 * optional, in format of email address 'you@yourdomain.com'355 * Used with DKIM Signing 356 * required if DKIM is enabled, path to private key file 306 357 * @var string 307 358 */ 308 359 public $DKIM_private = ''; 309 360 310 361 /** 311 * Callback Action function name 312 * the function that handles the result of the send email action. Parameters: 362 * Callback Action function name. 363 * The function that handles the result of the send email action. 364 * It is called out by Send() for each email sent. 365 * 366 * Value can be: 367 * - 'function_name' for function names 368 * - 'Class::Method' for static method calls 369 * - array($object, 'Method') for calling methods on $object 370 * See http://php.net/is_callable manual page for more details. 371 * 372 * Parameters: 313 373 * bool $result result of the send action 314 374 * string $to email address of the recipient 315 375 * string $cc cc email addresses 316 376 * string $bcc bcc email addresses 317 377 * string $subject the subject 318 378 * string $body the email body 379 * string $from email address of sender 319 380 * @var string 320 381 */ 321 382 public $action_function = ''; //'callbackAction'; … … class PHPMailer { 324 385 * Sets the PHPMailer Version number 325 386 * @var string 326 387 */ 327 public $Version = '5.2. 1';388 public $Version = '5.2.2-rc1'; 328 389 329 390 /** 330 391 * What to use in the X-Mailer header 331 * @var string 392 * @var string NULL for default, whitespace for None, or actual string to use 332 393 */ 333 394 public $XMailer = ''; 334 395 … … class PHPMailer { 360 421 const STOP_MESSAGE = 0; // message only, continue processing 361 422 const STOP_CONTINUE = 1; // message?, likely ok to continue processing 362 423 const STOP_CRITICAL = 2; // message, plus full stop, critical error reached 363 424 const CRLF = "\r\n"; // SMTP RFC specified EOL 425 364 426 ///////////////////////////////////////////////// 365 427 // METHODS, VARIABLES 366 428 ///////////////////////////////////////////////// 367 429 368 430 /** 431 * Calls actual mail() function, but in a safe_mode aware fashion 432 * Also, unless sendmail_path points to sendmail (or something that 433 * claims to be sendmail), don't pass params (not a perfect fix, 434 * but it will do) 435 * @param string $to To 436 * @param string $subject Subject 437 * @param string $body Message Body 438 * @param string $header Additional Header(s) 439 * @param string $params Params 440 * @access private 441 * @return bool 442 */ 443 private function mail_passthru($to, $subject, $body, $header, $params) { 444 if ( ini_get('safe_mode') || !($this->UseSendmailOptions) ) { 445 $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($subject)), $body, $header); 446 } else { 447 $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($subject)), $body, $header, $params); 448 } 449 return $rt; 450 } 451 452 /** 453 * Outputs debugging info via user-defined method 454 * @param string $str 455 */ 456 private function edebug($str) { 457 if ($this->Debugoutput == "error_log") { 458 error_log($str); 459 } else { 460 echo $str; 461 } 462 } 463 464 /** 369 465 * Constructor 370 466 * @param boolean $exceptions Should we throw external exceptions? 371 467 */ … … class PHPMailer { 389 485 /** 390 486 * Sets Mailer to send message using SMTP. 391 487 * @return void 488 * @deprecated 392 489 */ 393 490 public function IsSMTP() { 394 491 $this->Mailer = 'smtp'; … … class PHPMailer { 397 494 /** 398 495 * Sets Mailer to send message using PHP mail() function. 399 496 * @return void 497 * @deprecated 400 498 */ 401 499 public function IsMail() { 402 500 $this->Mailer = 'mail'; … … class PHPMailer { 405 503 /** 406 504 * Sets Mailer to send message using the $Sendmail program. 407 505 * @return void 506 * @deprecated 408 507 */ 409 508 public function IsSendmail() { 410 509 if (!stristr(ini_get('sendmail_path'), 'sendmail')) { … … class PHPMailer { 416 515 /** 417 516 * Sets Mailer to send message using the qmail MTA. 418 517 * @return void 518 * @deprecated 419 519 */ 420 520 public function IsQmail() { 421 521 if (stristr(ini_get('sendmail_path'), 'qmail')) { … … class PHPMailer { 485 585 if ($this->exceptions) { 486 586 throw new phpmailerException('Invalid recipient array: ' . $kind); 487 587 } 488 489 echo $this->Lang('Invalid recipient array').': '.$kind;588 if ($this->SMTPDebug) { 589 $this->edebug($this->Lang('Invalid recipient array').': '.$kind); 490 590 } 491 591 return false; 492 592 } 493 593 $address = trim($address); 494 594 $name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim 495 if (! self::ValidateAddress($address)) {595 if (!$this->ValidateAddress($address)) { 496 596 $this->SetError($this->Lang('invalid_address').': '. $address); 497 597 if ($this->exceptions) { 498 598 throw new phpmailerException($this->Lang('invalid_address').': '.$address); 499 599 } 500 501 echo $this->Lang('invalid_address').': '.$address;600 if ($this->SMTPDebug) { 601 $this->edebug($this->Lang('invalid_address').': '.$address); 502 602 } 503 603 return false; 504 604 } … … class PHPMailer { 521 621 * Set the From and FromName properties 522 622 * @param string $address 523 623 * @param string $name 624 * @param int $auto Also set Reply-To and Sender 524 625 * @return boolean 525 626 */ 526 627 public function SetFrom($address, $name = '', $auto = 1) { 527 628 $address = trim($address); 528 629 $name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim 529 if (! self::ValidateAddress($address)) {630 if (!$this->ValidateAddress($address)) { 530 631 $this->SetError($this->Lang('invalid_address').': '. $address); 531 632 if ($this->exceptions) { 532 633 throw new phpmailerException($this->Lang('invalid_address').': '.$address); 533 634 } 534 535 echo $this->Lang('invalid_address').': '.$address;635 if ($this->SMTPDebug) { 636 $this->edebug($this->Lang('invalid_address').': '.$address); 536 637 } 537 638 return false; 538 639 } … … class PHPMailer { 551 652 552 653 /** 553 654 * Check that a string looks roughly like an email address should 554 * Static so it can be used without instantiation 555 * Tries to use PHP built-in validator in the filter extension (from PHP 5.2), falls back to a reasonably competent regex validator 556 * Conforms approximately to RFC2822 557 * @link http://www.hexillion.com/samples/#Regex Original pattern found here 655 * Static so it can be used without instantiation, public so people can overload 656 * Conforms to RFC5322: Uses *correct* regex on which FILTER_VALIDATE_EMAIL is 657 * based; So why not use FILTER_VALIDATE_EMAIL? Because it was broken to 658 * not allow a@b type valid addresses :( 659 * @link http://squiloople.com/2009/12/20/email-address-validation/ 660 * @copyright regex Copyright Michael Rushton 2009-10 | http://squiloople.com/ | Feel free to use and redistribute this code. But please keep this copyright notice. 558 661 * @param string $address The email address to check 559 662 * @return boolean 560 663 * @static 561 664 * @access public 562 665 */ 563 666 public static function ValidateAddress($address) { 564 if (function_exists('filter_var')) { //Introduced in PHP 5.2 565 if(filter_var($address, FILTER_VALIDATE_EMAIL) === FALSE) { 566 return false; 567 } else { 568 return true; 569 } 570 } else { 571 return preg_match('/^(?:[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+\.)*[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+@(?:(?:(?:[a-zA-Z0-9_](?:[a-zA-Z0-9_\-](?!\.)){0,61}[a-zA-Z0-9_-]?\.)+[a-zA-Z0-9_](?:[a-zA-Z0-9_\-](?!$)){0,61}[a-zA-Z0-9_]?)|(?:\[(?:(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\.){3}(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\]))$/', $address); 572 } 667 return preg_match('/^(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){255,})(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){65,}@)((?>(?>(?>((?>(?>(?>\x0D\x0A)?[ ])+|(?>[ ]*\x0D\x0A)?[ ]+)?)(\((?>(?2)(?>[\x01-\x08\x0B\x0C\x0E-\'*-\[\]-\x7F]|\\\[\x00-\x7F]|(?3)))*(?2)\)))+(?2))|(?2))?)([!#-\'*+\/-9=?^-~-]+|"(?>(?2)(?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\\[\x00-\x7F]))*(?2)")(?>(?1)\.(?1)(?4))*(?1)@(?!(?1)[a-z0-9-]{64,})(?1)(?>([a-z0-9](?>[a-z0-9-]*[a-z0-9])?)(?>(?1)\.(?!(?1)[a-z0-9-]{64,})(?1)(?5)){0,126}|\[(?:(?>IPv6:(?>([a-f0-9]{1,4})(?>:(?6)){7}|(?!(?:.*[a-f0-9][:\]]){7,})((?6)(?>:(?6)){0,5})?::(?7)?))|(?>(?>IPv6:(?>(?6)(?>:(?6)){5}:|(?!(?:.*[a-f0-9]:){5,})(?8)?::(?>((?6)(?>:(?6)){0,3}):)?))?(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])(?>\.(?9)){3}))\])(?1)$/isD', $address); 573 668 } 574 669 575 670 ///////////////////////////////////////////////// … … class PHPMailer { 587 682 if(!$this->PreSend()) return false; 588 683 return $this->PostSend(); 589 684 } catch (phpmailerException $e) { 590 $this->SentMIMEMessage= '';685 $this->mailHeader = ''; 591 686 $this->SetError($e->getMessage()); 592 687 if ($this->exceptions) { 593 688 throw $e; … … class PHPMailer { 596 691 } 597 692 } 598 693 599 protected function PreSend() { 694 /** 695 * Prep mail by constructing all message entities 696 * @return bool 697 */ 698 public function PreSend() { 600 699 try { 601 $mailHeader = "";700 $this->mailHeader = ""; 602 701 if ((count($this->to) + count($this->cc) + count($this->bcc)) < 1) { 603 702 throw new phpmailerException($this->Lang('provide_address'), self::STOP_CRITICAL); 604 703 } … … class PHPMailer { 619 718 $this->MIMEBody = $this->CreateBody(); 620 719 621 720 // To capture the complete message when using mail(), create 622 721 // an extra header list which CreateHeader() doesn't fold in 623 722 if ($this->Mailer == 'mail') { 624 723 if (count($this->to) > 0) { 625 $ mailHeader .= $this->AddrAppend("To", $this->to);724 $this->mailHeader .= $this->AddrAppend("To", $this->to); 626 725 } else { 627 $ mailHeader .= $this->HeaderLine("To", "undisclosed-recipients:;");726 $this->mailHeader .= $this->HeaderLine("To", "undisclosed-recipients:;"); 628 727 } 629 $ mailHeader .= $this->HeaderLine('Subject', $this->EncodeHeader($this->SecureHeader(trim($this->Subject))));728 $this->mailHeader .= $this->HeaderLine('Subject', $this->EncodeHeader($this->SecureHeader(trim($this->Subject)))); 630 729 // if(count($this->cc) > 0) { 631 // $ mailHeader .= $this->AddrAppend("Cc", $this->cc);730 // $this->mailHeader .= $this->AddrAppend("Cc", $this->cc); 632 731 // } 633 732 } 634 733 635 734 // digitally sign with DKIM if enabled 636 if ( $this->DKIM_domain && $this->DKIM_private) {735 if (!empty($this->DKIM_domain) && !empty($this->DKIM_private) && !empty($this->DKIM_selector) && !empty($this->DKIM_domain) && file_exists($this->DKIM_private)) { 637 736 $header_dkim = $this->DKIM_Add($this->MIMEHeader, $this->EncodeHeader($this->SecureHeader($this->Subject)), $this->MIMEBody); 638 737 $this->MIMEHeader = str_replace("\r\n", "\n", $header_dkim) . $this->MIMEHeader; 639 738 } 640 739 641 $this->SentMIMEMessage = sprintf("%s%s\r\n\r\n%s",$this->MIMEHeader,$mailHeader,$this->MIMEBody);642 740 return true; 643 741 644 742 } catch (phpmailerException $e) { … … class PHPMailer { 650 748 } 651 749 } 652 750 653 protected function PostSend() { 751 /** 752 * Actual Email transport function 753 * Send the email via the selected mechanism 754 * @return bool 755 */ 756 public function PostSend() { 757 $rtn = false; 654 758 try { 655 759 // Choose the mailer and send through it 656 760 switch($this->Mailer) { 657 761 case 'sendmail': 658 return $this->SendmailSend($this->MIMEHeader, $this->MIMEBody); 762 $rtn = $this->SendmailSend($this->MIMEHeader, $this->MIMEBody); 763 break; 659 764 case 'smtp': 660 return $this->SmtpSend($this->MIMEHeader, $this->MIMEBody); 765 $rtn = $this->SmtpSend($this->MIMEHeader, $this->MIMEBody); 766 break; 661 767 case 'mail': 662 return $this->MailSend($this->MIMEHeader, $this->MIMEBody); 768 $rtn = $this->MailSend($this->MIMEHeader, $this->MIMEBody); 769 break; 663 770 default: 664 return $this->MailSend($this->MIMEHeader, $this->MIMEBody); 771 $rtn = $this->MailSend($this->MIMEHeader, $this->MIMEBody); 772 break; 665 773 } 666 774 667 775 } catch (phpmailerException $e) { … … class PHPMailer { 669 777 if ($this->exceptions) { 670 778 throw $e; 671 779 } 672 673 echo $e->getMessage()."\n";780 if ($this->SMTPDebug) { 781 $this->edebug($e->getMessage()."\n"); 674 782 } 675 783 return false; 676 784 } 785 return $rtn; 677 786 } 678 787 679 788 /** … … class PHPMailer { 744 853 if ($this->Sender != '' and !ini_get('safe_mode')) { 745 854 $old_from = ini_get('sendmail_from'); 746 855 ini_set('sendmail_from', $this->Sender); 747 if ($this->SingleTo === true && count($toArr) > 1) { 748 foreach ($toArr as $key => $val) { 749 $rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params); 750 // implement call back function if it exists 751 $isSent = ($rt == 1) ? 1 : 0; 752 $this->doCallback($isSent, $val, $this->cc, $this->bcc, $this->Subject, $body); 753 } 754 } else { 755 $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params); 856 } 857 if ($this->SingleTo === true && count($toArr) > 1) { 858 foreach ($toArr as $key => $val) { 859 $rt = $this->mail_passthru($val, $this->Subject, $body, $header, $params); 756 860 // implement call back function if it exists 757 861 $isSent = ($rt == 1) ? 1 : 0; 758 $this->doCallback($isSent, $ to, $this->cc, $this->bcc, $this->Subject, $body);862 $this->doCallback($isSent, $val, $this->cc, $this->bcc, $this->Subject, $body); 759 863 } 760 864 } else { 761 if ($this->SingleTo === true && count($toArr) > 1) { 762 foreach ($toArr as $key => $val) { 763 $rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header); 764 // implement call back function if it exists 765 $isSent = ($rt == 1) ? 1 : 0; 766 $this->doCallback($isSent, $val, $this->cc, $this->bcc, $this->Subject, $body); 767 } 768 } else { 769 $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header); 770 // implement call back function if it exists 771 $isSent = ($rt == 1) ? 1 : 0; 772 $this->doCallback($isSent, $to, $this->cc, $this->bcc, $this->Subject, $body); 773 } 865 $rt = $this->mail_passthru($to, $this->Subject, $body, $header, $params); 866 // implement call back function if it exists 867 $isSent = ($rt == 1) ? 1 : 0; 868 $this->doCallback($isSent, $to, $this->cc, $this->bcc, $this->Subject, $body); 774 869 } 775 870 if (isset($old_from)) { 776 871 ini_set('sendmail_from', $old_from); … … class PHPMailer { 862 957 * @return bool 863 958 */ 864 959 public function SmtpConnect() { 865 if (is_null($this->smtp)) {960 if ($this->smtp === null) { 866 961 $this->smtp = new SMTP(); 867 962 } 868 963 964 $this->smtp->Timeout = $this->Timeout; 869 965 $this->smtp->do_debug = $this->SMTPDebug; 870 966 $hosts = explode(';', $this->Host); 871 967 $index = 0; 872 968 $connection = $this->smtp->Connected(); 969 $rtn = true; 873 970 874 971 // Retry while there is no connection 875 972 try { … … class PHPMailer { 893 990 894 991 if ($tls) { 895 992 if (!$this->smtp->StartTLS()) { 993 $rtn = false; 896 994 throw new phpmailerException($this->Lang('tls')); 897 995 } 898 996 … … class PHPMailer { 902 1000 903 1001 $connection = true; 904 1002 if ($this->SMTPAuth) { 905 if (!$this->smtp->Authenticate($this->Username, $this->Password)) { 1003 if (!$this->smtp->Authenticate($this->Username, $this->Password, $this->AuthType, 1004 $this->Realm, $this->Workstation)) { 1005 $rtn = false; 906 1006 throw new phpmailerException($this->Lang('authenticate')); 907 1007 } 908 1008 } 909 1009 } 910 1010 $index++; 911 1011 if (!$connection) { 1012 $rtn = false; 912 1013 throw new phpmailerException($this->Lang('connect_host')); 913 1014 } 914 1015 } 915 1016 } catch (phpmailerException $e) { 916 1017 $this->smtp->Reset(); 917 1018 if ($this->exceptions) { 918 1019 throw $e; 919 1020 } 1021 $rtn = false; 920 1022 } 921 return true;1023 return $rtn; 922 1024 } 923 1025 924 1026 /** … … class PHPMailer { 926 1028 * @return void 927 1029 */ 928 1030 public function SmtpClose() { 929 if (!is_null($this->smtp)) {1031 if ($this->smtp !== null) { 930 1032 if($this->smtp->Connected()) { 931 1033 $this->smtp->Quit(); 932 1034 $this->smtp->Close(); … … class PHPMailer { 944 1046 function SetLanguage($langcode = 'en', $lang_path = 'language/') { 945 1047 //Define full set of translatable strings 946 1048 $PHPMAILER_LANG = array( 947 'provide_address' => 'You must provide at least one recipient email address.', 1049 'authenticate' => 'SMTP Error: Could not authenticate.', 1050 'connect_host' => 'SMTP Error: Could not connect to SMTP host.', 1051 'data_not_accepted' => 'SMTP Error: Data not accepted.', 1052 'empty_message' => 'Message body empty', 1053 'encoding' => 'Unknown encoding: ', 1054 'execute' => 'Could not execute: ', 1055 'file_access' => 'Could not access file: ', 1056 'file_open' => 'File Error: Could not open file: ', 1057 'from_failed' => 'The following From address failed: ', 1058 'instantiate' => 'Could not instantiate mail function.', 1059 'invalid_address' => 'Invalid address', 948 1060 'mailer_not_supported' => ' mailer is not supported.', 949 'execute' => 'Could not execute: ', 950 'instantiate' => 'Could not instantiate mail function.', 951 'authenticate' => 'SMTP Error: Could not authenticate.', 952 'from_failed' => 'The following From address failed: ', 953 'recipients_failed' => 'SMTP Error: The following recipients failed: ', 954 'data_not_accepted' => 'SMTP Error: Data not accepted.', 955 'connect_host' => 'SMTP Error: Could not connect to SMTP host.', 956 'file_access' => 'Could not access file: ', 957 'file_open' => 'File Error: Could not open file: ', 958 'encoding' => 'Unknown encoding: ', 959 'signing' => 'Signing Error: ', 960 'smtp_error' => 'SMTP server error: ', 961 'empty_message' => 'Message body empty', 962 'invalid_address' => 'Invalid address', 963 'variable_set' => 'Cannot set or reset variable: ' 1061 'provide_address' => 'You must provide at least one recipient email address.', 1062 'recipients_failed' => 'SMTP Error: The following recipients failed: ', 1063 'signing' => 'Signing Error: ', 1064 'smtp_connect_failed' => 'SMTP Connect() failed.', 1065 'smtp_error' => 'SMTP server error: ', 1066 'variable_set' => 'Cannot set or reset variable: ' 964 1067 ); 965 1068 //Overwrite language-specific strings. This way we'll never have missing translations - no more "language string failed to load"! 966 1069 $l = true; … … class PHPMailer { 1028 1131 // If utf-8 encoding is used, we will need to make sure we don't 1029 1132 // split multibyte characters when we wrap 1030 1133 $is_utf8 = (strtolower($this->CharSet) == "utf-8"); 1134 $lelen = strlen($this->LE); 1135 $crlflen = strlen(self::CRLF); 1031 1136 1032 1137 $message = $this->FixEOL($message); 1033 if (substr($message, - 1) == $this->LE) {1034 $message = substr($message, 0, - 1);1138 if (substr($message, -$lelen) == $this->LE) { 1139 $message = substr($message, 0, -$lelen); 1035 1140 } 1036 1141 1037 $line = explode($this->LE, $message); 1142 $line = explode($this->LE, $message); // Magic. We know FixEOL uses $LE 1038 1143 $message = ''; 1039 1144 for ($i = 0 ;$i < count($line); $i++) { 1040 1145 $line_part = explode(' ', $line[$i]); … … class PHPMailer { 1042 1147 for ($e = 0; $e<count($line_part); $e++) { 1043 1148 $word = $line_part[$e]; 1044 1149 if ($qp_mode and (strlen($word) > $length)) { 1045 $space_left = $length - strlen($buf) - 1;1150 $space_left = $length - strlen($buf) - $crlflen; 1046 1151 if ($e != 0) { 1047 1152 if ($space_left > 20) { 1048 1153 $len = $space_left; … … class PHPMailer { 1056 1161 $part = substr($word, 0, $len); 1057 1162 $word = substr($word, $len); 1058 1163 $buf .= ' ' . $part; 1059 $message .= $buf . sprintf("=%s", $this->LE);1164 $message .= $buf . sprintf("=%s", self::CRLF); 1060 1165 } else { 1061 1166 $message .= $buf . $soft_break; 1062 1167 } … … class PHPMailer { 1075 1180 $word = substr($word, $len); 1076 1181 1077 1182 if (strlen($word) > 0) { 1078 $message .= $part . sprintf("=%s", $this->LE);1183 $message .= $part . sprintf("=%s", self::CRLF); 1079 1184 } else { 1080 1185 $buf = $part; 1081 1186 } … … class PHPMailer { 1090 1195 } 1091 1196 } 1092 1197 } 1093 $message .= $buf . $this->LE;1198 $message .= $buf . self::CRLF; 1094 1199 } 1095 1200 1096 1201 return $message; … … class PHPMailer { 1176 1281 $this->boundary[3] = 'b3_' . $uniq_id; 1177 1282 1178 1283 $result .= $this->HeaderLine('Date', self::RFCDate()); 1179 if($this->Sender == '') { 1284 if ($this->ReturnPath) { 1285 $result .= $this->HeaderLine('Return-Path', trim($this->ReturnPath)); 1286 } elseif ($this->Sender == '') { 1180 1287 $result .= $this->HeaderLine('Return-Path', trim($this->From)); 1181 1288 } else { 1182 1289 $result .= $this->HeaderLine('Return-Path', trim($this->Sender)); … … class PHPMailer { 1195 1302 $result .= $this->HeaderLine('To', 'undisclosed-recipients:;'); 1196 1303 } 1197 1304 } 1198 1305 } 1199 1306 1200 1307 $from = array(); 1201 1308 $from[0][0] = trim($this->From); … … class PHPMailer { 1227 1334 $result .= sprintf("Message-ID: <%s@%s>%s", $uniq_id, $this->ServerHostname(), $this->LE); 1228 1335 } 1229 1336 $result .= $this->HeaderLine('X-Priority', $this->Priority); 1230 if ($this->XMailer) {1231 $result .= $this->HeaderLine('X-Mailer', $this->XMailer);1337 if ($this->XMailer == '') { 1338 $result .= $this->HeaderLine('X-Mailer', 'PHPMailer '.$this->Version.' (http://code.google.com/a/apache-extras.org/p/phpmailer/)'); 1232 1339 } else { 1233 $result .= $this->HeaderLine('X-Mailer', 'PHPMailer '.$this->Version.' (http://code.google.com/a/apache-extras.org/p/phpmailer/)'); 1340 $myXmailer = trim($this->XMailer); 1341 if ($myXmailer) { 1342 $result .= $this->HeaderLine('X-Mailer', $myXmailer); 1343 } 1234 1344 } 1235 1345 1236 1346 if($this->ConfirmReadingTo != '') { … … class PHPMailer { 1257 1367 public function GetMailMIME() { 1258 1368 $result = ''; 1259 1369 switch($this->message_type) { 1260 case 'plain':1261 $result .= $this->HeaderLine('Content-Transfer-Encoding', $this->Encoding);1262 $result .= $this->TextLine('Content-Type: '.$this->ContentType.'; charset="'.$this->CharSet.'"');1263 break;1264 1370 case 'inline': 1265 1371 $result .= $this->HeaderLine('Content-Type', 'multipart/related;'); 1266 1372 $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"'); … … class PHPMailer { 1277 1383 $result .= $this->HeaderLine('Content-Type', 'multipart/alternative;'); 1278 1384 $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"'); 1279 1385 break; 1386 default: 1387 // Catches case 'plain': and case '': 1388 $result .= $this->HeaderLine('Content-Transfer-Encoding', $this->Encoding); 1389 $result .= $this->TextLine('Content-Type: '.$this->ContentType.'; charset='.$this->CharSet); 1390 break; 1280 1391 } 1281 1392 1282 1393 if($this->Mailer != 'mail') { 1283 $result .= $this->LE .$this->LE;1394 $result .= $this->LE; 1284 1395 } 1285 1396 1286 1397 return $result; … … class PHPMailer { 1292 1403 * @return string 1293 1404 */ 1294 1405 public function GetSentMIMEMessage() { 1295 return $this-> SentMIMEMessage;1406 return $this->MIMEHeader . $this->mailHeader . self::CRLF . $this->MIMEBody; 1296 1407 } 1297 1408 1298 1409 … … class PHPMailer { 1305 1416 $body = ''; 1306 1417 1307 1418 if ($this->sign_key_file) { 1308 $body .= $this->GetMailMIME() ;1419 $body .= $this->GetMailMIME().$this->LE; 1309 1420 } 1310 1421 1311 1422 $this->SetWordWrap(); 1312 1423 1313 1424 switch($this->message_type) { 1314 case 'plain':1315 $body .= $this->EncodeString($this->Body, $this->Encoding);1316 break;1317 1425 case 'inline': 1318 1426 $body .= $this->GetBoundary($this->boundary[1], '', '', ''); 1319 1427 $body .= $this->EncodeString($this->Body, $this->Encoding); … … class PHPMailer { 1321 1429 $body .= $this->AttachAll("inline", $this->boundary[1]); 1322 1430 break; 1323 1431 case 'attach': 1324 $body .= $this->GetBoundary($this->boundary[1], '', ' ', '');1432 $body .= $this->GetBoundary($this->boundary[1], '', 'text/plain', ''); 1325 1433 $body .= $this->EncodeString($this->Body, $this->Encoding); 1326 1434 $body .= $this->LE.$this->LE; 1327 1435 $body .= $this->AttachAll("attachment", $this->boundary[1]); … … class PHPMailer { 1398 1506 $body .= $this->LE; 1399 1507 $body .= $this->AttachAll("attachment", $this->boundary[1]); 1400 1508 break; 1509 default: 1510 // catch case 'plain' and case '' 1511 $body .= $this->EncodeString($this->Body, $this->Encoding); 1512 break; 1401 1513 } 1402 1514 1403 1515 if ($this->IsError()) { … … class PHPMailer { 1444 1556 $encoding = $this->Encoding; 1445 1557 } 1446 1558 $result .= $this->TextLine('--' . $boundary); 1447 $result .= sprintf("Content-Type: %s; charset= \"%s\"", $contentType, $charSet);1559 $result .= sprintf("Content-Type: %s; charset=%s", $contentType, $charSet); 1448 1560 $result .= $this->LE; 1449 1561 $result .= $this->HeaderLine('Content-Transfer-Encoding', $encoding); 1450 1562 $result .= $this->LE; … … class PHPMailer { 1533 1645 if ($this->exceptions) { 1534 1646 throw $e; 1535 1647 } 1536 1537 echo $e->getMessage()."\n";1648 if ($this->SMTPDebug) { 1649 $this->edebug($e->getMessage()."\n"); 1538 1650 } 1539 1651 if ( $e->getCode() == self::STOP_CRITICAL ) { 1540 1652 return false; … … class PHPMailer { 1633 1745 if (!is_readable($path)) { 1634 1746 throw new phpmailerException($this->Lang('file_open') . $path, self::STOP_CONTINUE); 1635 1747 } 1636 if (function_exists('get_magic_quotes')) {1637 function get_magic_quotes() {1638 return false;1639 }1640 }1641 1642 1748 // if (!function_exists('get_magic_quotes')) { 1749 // function get_magic_quotes() { 1750 // return false; 1751 // } 1752 // } 1753 $magic_quotes = get_magic_quotes_runtime(); 1754 if ($magic_quotes) { 1643 1755 if (version_compare(PHP_VERSION, '5.3.0', '<')) { 1644 1756 set_magic_quotes_runtime(0); 1645 1757 } else { 1646 ini_set('magic_quotes_runtime', 0); 1647 1648 1758 ini_set('magic_quotes_runtime', 0); 1759 } 1760 } 1649 1761 $file_buffer = file_get_contents($path); 1650 1762 $file_buffer = $this->EncodeString($file_buffer, $encoding); 1651 1763 if ($magic_quotes) { 1652 1764 if (version_compare(PHP_VERSION, '5.3.0', '<')) { 1653 1765 set_magic_quotes_runtime($magic_quotes); 1654 1766 } else { 1655 ini_set('magic_quotes_runtime', $magic_quotes); 1656 1657 1767 ini_set('magic_quotes_runtime', $magic_quotes); 1768 } 1769 } 1658 1770 return $file_buffer; 1659 1771 } catch (Exception $e) { 1660 1772 $this->SetError($e->getMessage()); … … class PHPMailer { 1737 1849 if (function_exists('mb_strlen') && $this->HasMultiBytes($str)) { 1738 1850 // Use a custom function which correctly encodes and wraps long 1739 1851 // multibyte strings without breaking lines within a character 1740 $encoded = $this->Base64EncodeWrapMB($str );1852 $encoded = $this->Base64EncodeWrapMB($str, "\n"); 1741 1853 } else { 1742 1854 $encoded = base64_encode($str); 1743 1855 $maxlen -= $maxlen % 4; … … class PHPMailer { 1747 1859 $encoding = 'Q'; 1748 1860 $encoded = $this->EncodeQ($str, $position); 1749 1861 $encoded = $this->WrapText($encoded, $maxlen, true); 1750 $encoded = str_replace('='. $this->LE, "\n", trim($encoded));1862 $encoded = str_replace('='.self::CRLF, "\n", trim($encoded)); 1751 1863 } 1752 1864 1753 1865 $encoded = preg_replace('/^(.*)$/m', " =?".$this->CharSet."?$encoding?\\1?=", $encoded); … … class PHPMailer { 1776 1888 * Adapted from a function by paravoid at http://uk.php.net/manual/en/function.mb-encode-mimeheader.php 1777 1889 * @access public 1778 1890 * @param string $str multi-byte text to wrap encode 1891 * @param string $lf string to use as linefeed/end-of-line 1779 1892 * @return string 1780 1893 */ 1781 public function Base64EncodeWrapMB($str ) {1894 public function Base64EncodeWrapMB($str, $lf=null) { 1782 1895 $start = "=?".$this->CharSet."?B?"; 1783 1896 $end = "?="; 1784 1897 $encoded = ""; 1898 if ($lf === null) { 1899 $lf = $this->LE; 1900 } 1785 1901 1786 1902 $mb_length = mb_strlen($str, $this->CharSet); 1787 1903 // Each line must have length <= 75, including $start and $end … … class PHPMailer { 1802 1918 } 1803 1919 while (strlen($chunk) > $length); 1804 1920 1805 $encoded .= $chunk . $ this->LE;1921 $encoded .= $chunk . $lf; 1806 1922 } 1807 1923 1808 1924 // Chomp the last linefeed 1809 $encoded = substr($encoded, 0, -strlen($ this->LE));1925 $encoded = substr($encoded, 0, -strlen($lf)); 1810 1926 return $encoded; 1811 1927 } 1812 1928 … … class PHPMailer { 1901 2017 * @return string 1902 2018 */ 1903 2019 public function EncodeQ($str, $position = 'text') { 1904 // 1905 $encoded = preg_replace('/[\r\n]*/', '', $str);1906 2020 //There should not be any EOL in the string 2021 $pattern=""; 2022 $encoded = str_replace(array("\r", "\n"), '', $str); 1907 2023 switch (strtolower($position)) { 1908 2024 case 'phrase': 1909 $ encoded = preg_replace("/([^A-Za-z0-9!*+\/ -])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded);2025 $pattern = '^A-Za-z0-9!*+\/ -'; 1910 2026 break; 2027 1911 2028 case 'comment': 1912 $encoded = preg_replace("/([\(\)\"])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded); 2029 $pattern = '\(\)"'; 2030 //note that we dont break here! 2031 //for this reason we build the $pattern withoud including delimiters and [] 2032 1913 2033 case 'text': 1914 2034 default: 1915 // Replace every high ascii, control =, ? and _ characters 1916 //TODO using /e (equivalent to eval()) is probably not a good idea 1917 $encoded = preg_replace('/([\000-\011\013\014\016-\037\075\077\137\177-\377])/e', 1918 "'='.sprintf('%02X', ord(stripslashes('\\1')))", $encoded); 2035 //Replace every high ascii, control =, ? and _ characters 2036 //We put \075 (=) as first value to make sure it's the first one in being converted, preventing double encode 2037 $pattern = '\075\000-\011\013\014\016-\037\077\137\177-\377' . $pattern; 1919 2038 break; 1920 2039 } 2040 2041 if (preg_match_all("/[{$pattern}]/", $encoded, $matches)) { 2042 foreach (array_unique($matches[0]) as $char) { 2043 $encoded = str_replace($char, '=' . sprintf('%02X', ord($char)), $encoded); 2044 } 2045 } 2046 2047 //Replace every spaces to _ (more readable than =20) 2048 return str_replace(' ', '_', $encoded); 2049 } 1921 2050 1922 // Replace every spaces to _ (more readable than =20)1923 $encoded = str_replace(' ', '_', $encoded);1924 1925 return $encoded;1926 }1927 2051 1928 2052 /** 1929 2053 * Adds a string or binary attachment (non-filesystem) to the list. … … class PHPMailer { 2027 2151 } 2028 2152 2029 2153 public function AlternativeExists() { 2030 return strlen($this->AltBody)>0;2154 return !empty($this->AltBody); 2031 2155 } 2032 2156 2033 2157 ///////////////////////////////////////////////// … … class PHPMailer { 2115 2239 */ 2116 2240 protected function SetError($msg) { 2117 2241 $this->error_count++; 2118 if ( $this->Mailer == 'smtp' and !is_null($this->smtp)) {2242 if (($this->Mailer == 'smtp') and ($this->smtp !== null)) { 2119 2243 $lasterror = $this->smtp->getError(); 2120 2244 if (!empty($lasterror) and array_key_exists('smtp_msg', $lasterror)) { 2121 2245 $msg .= '<p>' . $this->Lang('smtp_error') . $lasterror['smtp_msg'] . "</p>\n"; … … class PHPMailer { 2184 2308 } 2185 2309 2186 2310 /** 2187 * Changes every end of line from CR or LF to CRLF.2311 * Changes every end of line from CRLF, CR or LF to $this->LE. 2188 2312 * @access public 2313 * @param string $str String to FixEOL 2189 2314 * @return string 2190 2315 */ 2191 2316 public function FixEOL($str) { 2192 $str = str_replace("\r\n", "\n", $str); 2193 $str = str_replace("\r", "\n", $str); 2194 $str = str_replace("\n", $this->LE, $str); 2195 return $str; 2317 // condense down to \n 2318 $nstr = str_replace(array("\r\n", "\r"), "\n", $str); 2319 // Now convert LE as needed 2320 if ($this->LE !== "\n") { 2321 $nstr = str_replace("\n", $this->LE, $nstr); 2322 } 2323 return $nstr; 2196 2324 } 2197 2325 2198 2326 /** 2199 * Adds a custom header. 2327 * Adds a custom header. $name value can be overloaded to contain 2328 * both header name and value (name:value) 2200 2329 * @access public 2330 * @param string $name custom header name 2331 * @param string $value header value 2201 2332 * @return void 2202 2333 */ 2203 public function AddCustomHeader($custom_header) { 2204 $this->CustomHeader[] = explode(':', $custom_header, 2); 2334 public function AddCustomHeader($name, $value=null) { 2335 if ($value === null) { 2336 // Value passed in as name:value 2337 $this->CustomHeader[] = explode(':', $name, 2); 2338 } else { 2339 $this->CustomHeader[] = array($name, $value); 2340 } 2205 2341 } 2206 2342 2207 2343 /** 2208 2344 * Evaluates the message and returns modifications for inline images and backgrounds 2209 2345 * @access public 2346 * @param string $message Text to be HTML modified 2347 * @param string $basedir baseline directory for path 2210 2348 * @return $message 2211 2349 */ 2212 2350 public function MsgHTML($message, $basedir = '') { … … class PHPMailer { 2231 2369 } 2232 2370 $this->IsHTML(true); 2233 2371 $this->Body = $message; 2234 2235 2236 2237 2238 2239 2372 if (empty($this->AltBody)) { 2373 $textMsg = trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/s', '', $message))); 2374 if (!empty($textMsg)) { 2375 $this->AltBody = html_entity_decode($textMsg, ENT_QUOTES, $this->CharSet); 2376 } 2377 } 2240 2378 if (empty($this->AltBody)) { 2241 2379 $this->AltBody = 'To view this email message, open it in a program that understands HTML!' . "\n\n"; 2242 2380 } 2243 2381 return $message; 2244 2382 } 2245 2383 2246 2384 /** 2247 2385 * Gets the MIME type of the embedded or inline image 2248 * @param string File extension2386 * @param string $ext File extension 2249 2387 * @access public 2250 2388 * @return string MIME type of ext 2251 2389 * @static 2252 2390 */ 2253 2391 public static function _mime_types($ext = '') { 2254 2392 $mimes = array( 2393 'xl' => 'application/excel', 2255 2394 'hqx' => 'application/mac-binhex40', 2256 2395 'cpt' => 'application/mac-compactpro', 2257 'doc' => 'application/msword',2258 2396 'bin' => 'application/macbinary', 2397 'doc' => 'application/msword', 2398 'doc' => 'application/msword', 2399 'word' => 'application/msword', 2400 'class' => 'application/octet-stream', 2401 'dll' => 'application/octet-stream', 2259 2402 'dms' => 'application/octet-stream', 2403 'exe' => 'application/octet-stream', 2260 2404 'lha' => 'application/octet-stream', 2261 2405 'lzh' => 'application/octet-stream', 2262 'exe' => 'application/octet-stream',2263 'class' => 'application/octet-stream',2264 2406 'psd' => 'application/octet-stream', 2265 'so' => 'application/octet-stream',2266 2407 'sea' => 'application/octet-stream', 2267 ' dll'=> 'application/octet-stream',2408 'so' => 'application/octet-stream', 2268 2409 'oda' => 'application/oda', 2269 2410 'pdf' => 'application/pdf', 2270 2411 'ai' => 'application/postscript', … … class PHPMailer { 2282 2423 'dxr' => 'application/x-director', 2283 2424 'dvi' => 'application/x-dvi', 2284 2425 'gtar' => 'application/x-gtar', 2285 'php' => 'application/x-httpd-php',2286 'php4' => 'application/x-httpd-php',2287 2426 'php3' => 'application/x-httpd-php', 2427 'php4' => 'application/x-httpd-php', 2428 'php' => 'application/x-httpd-php', 2288 2429 'phtml' => 'application/x-httpd-php', 2289 2430 'phps' => 'application/x-httpd-php-source', 2290 2431 'js' => 'application/x-javascript', … … class PHPMailer { 2292 2433 'sit' => 'application/x-stuffit', 2293 2434 'tar' => 'application/x-tar', 2294 2435 'tgz' => 'application/x-tar', 2295 'xhtml' => 'application/xhtml+xml',2296 2436 'xht' => 'application/xhtml+xml', 2437 'xhtml' => 'application/xhtml+xml', 2297 2438 'zip' => 'application/zip', 2298 2439 'mid' => 'audio/midi', 2299 2440 'midi' => 'audio/midi', 2300 'mpga' => 'audio/mpeg',2301 2441 'mp2' => 'audio/mpeg', 2302 2442 'mp3' => 'audio/mpeg', 2443 'mpga' => 'audio/mpeg', 2303 2444 'aif' => 'audio/x-aiff', 2304 'aiff' => 'audio/x-aiff',2305 2445 'aifc' => 'audio/x-aiff', 2446 'aiff' => 'audio/x-aiff', 2306 2447 'ram' => 'audio/x-pn-realaudio', 2307 2448 'rm' => 'audio/x-pn-realaudio', 2308 2449 'rpm' => 'audio/x-pn-realaudio-plugin', 2309 2450 'ra' => 'audio/x-realaudio', 2310 'rv' => 'video/vnd.rn-realvideo',2311 2451 'wav' => 'audio/x-wav', 2312 2452 'bmp' => 'image/bmp', 2313 2453 'gif' => 'image/gif', 2314 2454 'jpeg' => 'image/jpeg', 2315 'jpg' => 'image/jpeg',2316 2455 'jpe' => 'image/jpeg', 2456 'jpg' => 'image/jpeg', 2317 2457 'png' => 'image/png', 2318 2458 'tiff' => 'image/tiff', 2319 2459 'tif' => 'image/tiff', 2460 'eml' => 'message/rfc822', 2320 2461 'css' => 'text/css', 2321 2462 'html' => 'text/html', 2322 2463 'htm' => 'text/html', 2323 2464 'shtml' => 'text/html', 2324 'txt' => 'text/plain',2325 'text' => 'text/plain',2326 2465 'log' => 'text/plain', 2466 'text' => 'text/plain', 2467 'txt' => 'text/plain', 2327 2468 'rtx' => 'text/richtext', 2328 2469 'rtf' => 'text/rtf', 2329 2470 'xml' => 'text/xml', 2330 2471 'xsl' => 'text/xml', 2331 2472 'mpeg' => 'video/mpeg', 2332 'mpg' => 'video/mpeg',2333 2473 'mpe' => 'video/mpeg', 2334 ' qt' => 'video/quicktime',2474 'mpg' => 'video/mpeg', 2335 2475 'mov' => 'video/quicktime', 2476 'qt' => 'video/quicktime', 2477 'rv' => 'video/vnd.rn-realvideo', 2336 2478 'avi' => 'video/x-msvideo', 2337 'movie' => 'video/x-sgi-movie', 2338 'doc' => 'application/msword', 2339 'word' => 'application/msword', 2340 'xl' => 'application/excel', 2341 'eml' => 'message/rfc822' 2479 'movie' => 'video/x-sgi-movie' 2342 2480 ); 2343 2481 return (!isset($mimes[strtolower($ext)])) ? 'application/octet-stream' : $mimes[strtolower($ext)]; 2344 2482 } … … class PHPMailer { 2378 2516 * @return string 2379 2517 */ 2380 2518 public function SecureHeader($str) { 2381 $str = str_replace("\r", '', $str); 2382 $str = str_replace("\n", '', $str); 2383 return trim($str); 2519 return trim(str_replace(array("\r", "\n"), '', $str)); 2384 2520 } 2385 2521 2386 2522 /** … … class PHPMailer { 2515 2651 return "X-PHPMAILER-DKIM: phpmailer.worxware.com\r\n".$dkimhdrs.$signed."\r\n"; 2516 2652 } 2517 2653 2518 protected function doCallback($isSent, $to, $cc, $bcc, $subject, $body) { 2519 if (!empty($this->action_function) && function_exists($this->action_function)) { 2520 $params = array($isSent, $to, $cc, $bcc, $subject, $body); 2654 /** 2655 * Perform callback 2656 */ 2657 protected function doCallback($isSent, $to, $cc, $bcc, $subject, $body, $from=null) { 2658 if (!empty($this->action_function) && is_callable($this->action_function)) { 2659 $params = array($isSent, $to, $cc, $bcc, $subject, $body, $from); 2521 2660 call_user_func_array($this->action_function, $params); 2522 2661 } 2523 2662 } 2524 2663 } 2525 2664 2665 /** 2666 * Exception handling 2667 */ 2526 2668 class phpmailerException extends Exception { 2527 2669 public function errorMessage() { 2528 2670 $errorMsg = '<strong>' . $this->getMessage() . "</strong><br />\n"; -
wp-includes/class-smtp.php
diff --git wp-includes/class-smtp.php wp-includes/class-smtp.php index 6977bff..66d5064 100644
2 2 /*~ class.smtp.php 3 3 .---------------------------------------------------------------------------. 4 4 | Software: PHPMailer - PHP email class | 5 | Version: 5.2. 1|5 | Version: 5.2.2 | 6 6 | Site: https://code.google.com/a/apache-extras.org/p/phpmailer/ | 7 7 | ------------------------------------------------------------------------- | 8 8 | Admin: Jim Jagielski (project admininistrator) | … … 32 32 * @author Jim Jagielski 33 33 * @copyright 2010 - 2012 Jim Jagielski 34 34 * @license http://www.gnu.org/copyleft/lesser.html Distributed under the Lesser General Public License (LGPL) 35 * @version $Id: class.smtp.php 450 2010-06-23 16:46:33Z coolbru $36 35 */ 37 36 38 37 /** … … class SMTP { 51 50 public $SMTP_PORT = 25; 52 51 53 52 /** 54 * SMTP reply line ending 53 * SMTP reply line ending (don't change) 55 54 * @var string 56 55 */ 57 56 public $CRLF = "\r\n"; … … class SMTP { 63 62 public $do_debug; // the level of debug to perform 64 63 65 64 /** 65 * Sets the function/method to use for debugging output. 66 * Right now we only honor "echo" or "error_log" 67 * @var string 68 */ 69 public $Debugoutput = "echo"; 70 71 /** 66 72 * Sets VERP use on/off (default is off) 67 73 * @var bool 68 74 */ 69 75 public $do_verp = false; 70 76 71 77 /** 78 * Sets the SMTP timeout value for reads, in seconds 79 * @var int 80 */ 81 public $Timeout = 15; 82 83 /** 84 * Sets the SMTP timelimit value for reads, in seconds 85 * @var int 86 */ 87 public $Timelimit = 30; 88 89 /** 72 90 * Sets the SMTP PHPMailer Version number 73 91 * @var string 74 92 */ 75 public $Version = '5.2. 1';93 public $Version = '5.2.2-rc1'; 76 94 77 95 ///////////////////////////////////////////////// 78 96 // PROPERTIES, PRIVATE AND PROTECTED … … class SMTP { 83 101 private $helo_rply; // the reply the server sent to us for HELO 84 102 85 103 /** 104 * Outputs debugging info via user-defined method 105 * @param string $str 106 */ 107 private function edebug($str) { 108 if ($this->Debugoutput == "error_log") { 109 error_log($str); 110 } else { 111 echo $str; 112 } 113 } 114 115 /** 86 116 * Initialize the class so that the data is in a known state. 87 117 * @access public 88 118 * @return void … … class SMTP { 139 169 "errno" => $errno, 140 170 "errstr" => $errstr); 141 171 if($this->do_debug >= 1) { 142 echo "SMTP -> ERROR: " . $this->error["error"] . ": $errstr ($errno)" . $this->CRLF . '<br />';172 $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": $errstr ($errno)" . $this->CRLF . '<br />'); 143 173 } 144 174 return false; 145 175 } 146 176 147 177 // SMTP server can take longer to respond, give longer timeout for first read 148 178 // Windows does not have support for this timeout function 149 if(substr(PHP_OS, 0, 3) != "WIN") 150 socket_set_timeout($this->smtp_conn, $tval, 0); 179 if(substr(PHP_OS, 0, 3) != "WIN") { 180 $max = ini_get('max_execution_time'); 181 if ($max != 0 && $tval > $max) { // don't bother if unlimited 182 @set_time_limit($tval); 183 } 184 stream_set_timeout($this->smtp_conn, $tval, 0); 185 } 151 186 152 187 // get any announcement 153 188 $announce = $this->get_lines(); 154 189 155 190 if($this->do_debug >= 2) { 156 echo "SMTP -> FROM SERVER:" . $announce . $this->CRLF . '<br />';191 $this->edebug("SMTP -> FROM SERVER:" . $announce . $this->CRLF . '<br />'); 157 192 } 158 193 159 194 return true; … … class SMTP { 182 217 $code = substr($rply,0,3); 183 218 184 219 if($this->do_debug >= 2) { 185 echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';220 $this->edebug("SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'); 186 221 } 187 222 188 223 if($code != 220) { … … class SMTP { 191 226 "smtp_code" => $code, 192 227 "smtp_msg" => substr($rply,4)); 193 228 if($this->do_debug >= 1) { 194 echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';229 $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'); 195 230 } 196 231 return false; 197 232 } … … class SMTP { 210 245 * @access public 211 246 * @return bool 212 247 */ 213 public function Authenticate($username, $password) { 214 // Start authentication 215 fputs($this->smtp_conn,"AUTH LOGIN" . $this->CRLF); 216 217 $rply = $this->get_lines(); 218 $code = substr($rply,0,3); 219 220 if($code != 334) { 221 $this->error = 222 array("error" => "AUTH not accepted from server", 223 "smtp_code" => $code, 224 "smtp_msg" => substr($rply,4)); 225 if($this->do_debug >= 1) { 226 echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'; 227 } 228 return false; 229 } 230 231 // Send encoded username 232 fputs($this->smtp_conn, base64_encode($username) . $this->CRLF); 233 234 $rply = $this->get_lines(); 235 $code = substr($rply,0,3); 236 237 if($code != 334) { 238 $this->error = 239 array("error" => "Username not accepted from server", 240 "smtp_code" => $code, 241 "smtp_msg" => substr($rply,4)); 242 if($this->do_debug >= 1) { 243 echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'; 244 } 245 return false; 246 } 247 248 // Send encoded password 249 fputs($this->smtp_conn, base64_encode($password) . $this->CRLF); 250 251 $rply = $this->get_lines(); 252 $code = substr($rply,0,3); 253 254 if($code != 235) { 255 $this->error = 256 array("error" => "Password not accepted from server", 257 "smtp_code" => $code, 258 "smtp_msg" => substr($rply,4)); 259 if($this->do_debug >= 1) { 260 echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'; 261 } 262 return false; 248 public function Authenticate($username, $password, $authtype='LOGIN', $realm='', 249 $workstation='') { 250 if (empty($authtype)) { 251 $authtype = 'LOGIN'; 252 } 253 254 switch ($authtype) { 255 case 'PLAIN': 256 // Start authentication 257 fputs($this->smtp_conn,"AUTH PLAIN" . $this->CRLF); 258 259 $rply = $this->get_lines(); 260 $code = substr($rply,0,3); 261 262 if($code != 334) { 263 $this->error = 264 array("error" => "AUTH not accepted from server", 265 "smtp_code" => $code, 266 "smtp_msg" => substr($rply,4)); 267 if($this->do_debug >= 1) { 268 $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'); 269 } 270 return false; 271 } 272 // Send encoded username and password 273 fputs($this->smtp_conn, base64_encode("\0".$username."\0".$password) . $this->CRLF); 274 275 $rply = $this->get_lines(); 276 $code = substr($rply,0,3); 277 278 if($code != 235) { 279 $this->error = 280 array("error" => "Authentication not accepted from server", 281 "smtp_code" => $code, 282 "smtp_msg" => substr($rply,4)); 283 if($this->do_debug >= 1) { 284 $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'); 285 } 286 return false; 287 } 288 break; 289 case 'LOGIN': 290 // Start authentication 291 fputs($this->smtp_conn,"AUTH LOGIN" . $this->CRLF); 292 293 $rply = $this->get_lines(); 294 $code = substr($rply,0,3); 295 296 if($code != 334) { 297 $this->error = 298 array("error" => "AUTH not accepted from server", 299 "smtp_code" => $code, 300 "smtp_msg" => substr($rply,4)); 301 if($this->do_debug >= 1) { 302 $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'); 303 } 304 return false; 305 } 306 307 // Send encoded username 308 fputs($this->smtp_conn, base64_encode($username) . $this->CRLF); 309 310 $rply = $this->get_lines(); 311 $code = substr($rply,0,3); 312 313 if($code != 334) { 314 $this->error = 315 array("error" => "Username not accepted from server", 316 "smtp_code" => $code, 317 "smtp_msg" => substr($rply,4)); 318 if($this->do_debug >= 1) { 319 $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'); 320 } 321 return false; 322 } 323 324 // Send encoded password 325 fputs($this->smtp_conn, base64_encode($password) . $this->CRLF); 326 327 $rply = $this->get_lines(); 328 $code = substr($rply,0,3); 329 330 if($code != 235) { 331 $this->error = 332 array("error" => "Password not accepted from server", 333 "smtp_code" => $code, 334 "smtp_msg" => substr($rply,4)); 335 if($this->do_debug >= 1) { 336 $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'); 337 } 338 return false; 339 } 340 break; 341 case 'NTLM': 342 /* 343 * ntlm_sasl_client.php 344 ** Bundled with Permission 345 ** 346 ** How to telnet in windows: http://technet.microsoft.com/en-us/library/aa995718%28EXCHG.65%29.aspx 347 ** PROTOCOL Documentation http://curl.haxx.se/rfc/ntlm.html#ntlmSmtpAuthentication 348 */ 349 require_once('ntlm_sasl_client.php'); 350 $temp = new stdClass(); 351 $ntlm_client = new ntlm_sasl_client_class; 352 if(! $ntlm_client->Initialize($temp)){//let's test if every function its available 353 $this->error = array("error" => $temp->error); 354 if($this->do_debug >= 1) { 355 $this->edebug("You need to enable some modules in your php.ini file: " . $this->error["error"] . $this->CRLF); 356 } 357 return false; 358 } 359 $msg1 = $ntlm_client->TypeMsg1($realm, $workstation);//msg1 360 361 fputs($this->smtp_conn,"AUTH NTLM " . base64_encode($msg1) . $this->CRLF); 362 363 $rply = $this->get_lines(); 364 $code = substr($rply,0,3); 365 366 367 if($code != 334) { 368 $this->error = 369 array("error" => "AUTH not accepted from server", 370 "smtp_code" => $code, 371 "smtp_msg" => substr($rply,4)); 372 if($this->do_debug >= 1) { 373 $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF); 374 } 375 return false; 376 } 377 378 $challange = substr($rply,3);//though 0 based, there is a white space after the 3 digit number....//msg2 379 $challange = base64_decode($challange); 380 $ntlm_res = $ntlm_client->NTLMResponse(substr($challange,24,8),$password); 381 $msg3 = $ntlm_client->TypeMsg3($ntlm_res,$username,$realm,$workstation);//msg3 382 // Send encoded username 383 fputs($this->smtp_conn, base64_encode($msg3) . $this->CRLF); 384 385 $rply = $this->get_lines(); 386 $code = substr($rply,0,3); 387 388 if($code != 235) { 389 $this->error = 390 array("error" => "Could not authenticate", 391 "smtp_code" => $code, 392 "smtp_msg" => substr($rply,4)); 393 if($this->do_debug >= 1) { 394 $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF); 395 } 396 return false; 397 } 398 break; 263 399 } 264 265 400 return true; 266 401 } 267 402 … … class SMTP { 276 411 if($sock_status["eof"]) { 277 412 // the socket is valid but we are not connected 278 413 if($this->do_debug >= 1) { 279 echo "SMTP -> NOTICE:" . $this->CRLF . "EOF caught while checking if connected";414 $this->edebug("SMTP -> NOTICE:" . $this->CRLF . "EOF caught while checking if connected"); 280 415 } 281 416 $this->Close(); 282 417 return false; … … class SMTP { 341 476 $code = substr($rply,0,3); 342 477 343 478 if($this->do_debug >= 2) { 344 echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';479 $this->edebug("SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'); 345 480 } 346 481 347 482 if($code != 354) { … … class SMTP { 350 485 "smtp_code" => $code, 351 486 "smtp_msg" => substr($rply,4)); 352 487 if($this->do_debug >= 1) { 353 echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';488 $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'); 354 489 } 355 490 return false; 356 491 } … … class SMTP { 435 570 $code = substr($rply,0,3); 436 571 437 572 if($this->do_debug >= 2) { 438 echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';573 $this->edebug("SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'); 439 574 } 440 575 441 576 if($code != 250) { … … class SMTP { 444 579 "smtp_code" => $code, 445 580 "smtp_msg" => substr($rply,4)); 446 581 if($this->do_debug >= 1) { 447 echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';582 $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'); 448 583 } 449 584 return false; 450 585 } … … class SMTP { 500 635 $code = substr($rply,0,3); 501 636 502 637 if($this->do_debug >= 2) { 503 echo "SMTP -> FROM SERVER: " . $rply . $this->CRLF . '<br />';638 $this->edebug("SMTP -> FROM SERVER: " . $rply . $this->CRLF . '<br />'); 504 639 } 505 640 506 641 if($code != 250) { … … class SMTP { 509 644 "smtp_code" => $code, 510 645 "smtp_msg" => substr($rply,4)); 511 646 if($this->do_debug >= 1) { 512 echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';647 $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'); 513 648 } 514 649 return false; 515 650 } … … class SMTP { 542 677 return false; 543 678 } 544 679 545 $useVerp = ($this->do_verp ? " XVERP" : "");680 $useVerp = ($this->do_verp ? " XVERP" : ""); 546 681 fputs($this->smtp_conn,"MAIL FROM:<" . $from . ">" . $useVerp . $this->CRLF); 547 682 548 683 $rply = $this->get_lines(); 549 684 $code = substr($rply,0,3); 550 685 551 686 if($this->do_debug >= 2) { 552 echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';687 $this->edebug("SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'); 553 688 } 554 689 555 690 if($code != 250) { … … class SMTP { 558 693 "smtp_code" => $code, 559 694 "smtp_msg" => substr($rply,4)); 560 695 if($this->do_debug >= 1) { 561 echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';696 $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'); 562 697 } 563 698 return false; 564 699 } … … class SMTP { 592 727 $byemsg = $this->get_lines(); 593 728 594 729 if($this->do_debug >= 2) { 595 echo "SMTP -> FROM SERVER:" . $byemsg . $this->CRLF . '<br />';730 $this->edebug("SMTP -> FROM SERVER:" . $byemsg . $this->CRLF . '<br />'); 596 731 } 597 732 598 733 $rval = true; … … class SMTP { 606 741 "smtp_rply" => substr($byemsg,4)); 607 742 $rval = false; 608 743 if($this->do_debug >= 1) { 609 echo "SMTP -> ERROR: " . $e["error"] . ": " . $byemsg . $this->CRLF . '<br />';744 $this->edebug("SMTP -> ERROR: " . $e["error"] . ": " . $byemsg . $this->CRLF . '<br />'); 610 745 } 611 746 } 612 747 … … class SMTP { 644 779 $code = substr($rply,0,3); 645 780 646 781 if($this->do_debug >= 2) { 647 echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';782 $this->edebug("SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'); 648 783 } 649 784 650 785 if($code != 250 && $code != 251) { … … class SMTP { 653 788 "smtp_code" => $code, 654 789 "smtp_msg" => substr($rply,4)); 655 790 if($this->do_debug >= 1) { 656 echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';791 $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'); 657 792 } 658 793 return false; 659 794 } … … class SMTP { 687 822 $code = substr($rply,0,3); 688 823 689 824 if($this->do_debug >= 2) { 690 echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';825 $this->edebug("SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'); 691 826 } 692 827 693 828 if($code != 250) { … … class SMTP { 696 831 "smtp_code" => $code, 697 832 "smtp_msg" => substr($rply,4)); 698 833 if($this->do_debug >= 1) { 699 echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';834 $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'); 700 835 } 701 836 return false; 702 837 } … … class SMTP { 735 870 $code = substr($rply,0,3); 736 871 737 872 if($this->do_debug >= 2) { 738 echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';873 $this->edebug("SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'); 739 874 } 740 875 741 876 if($code != 250) { … … class SMTP { 744 879 "smtp_code" => $code, 745 880 "smtp_msg" => substr($rply,4)); 746 881 if($this->do_debug >= 1) { 747 echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';882 $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'); 748 883 } 749 884 return false; 750 885 } … … class SMTP { 768 903 $this->error = array("error" => "This method, TURN, of the SMTP ". 769 904 "is not implemented"); 770 905 if($this->do_debug >= 1) { 771 echo "SMTP -> NOTICE: " . $this->error["error"] . $this->CRLF . '<br />';906 $this->edebug("SMTP -> NOTICE: " . $this->error["error"] . $this->CRLF . '<br />'); 772 907 } 773 908 return false; 774 909 } … … class SMTP { 797 932 */ 798 933 private function get_lines() { 799 934 $data = ""; 800 while(!feof($this->smtp_conn)) { 935 $endtime = 0; 936 /* If for some reason the fp is bad, don't inf loop */ 937 if (!is_resource($this->smtp_conn)) { 938 return $data; 939 } 940 stream_set_timeout($this->smtp_conn, $this->Timeout); 941 if ($this->Timelimit > 0) { 942 $endtime = time() + $this->Timelimit; 943 } 944 while(is_resource($this->smtp_conn) && !feof($this->smtp_conn)) { 801 945 $str = @fgets($this->smtp_conn,515); 802 946 if($this->do_debug >= 4) { 803 echo "SMTP -> get_lines(): \$data was \"$data\"" . $this->CRLF . '<br />';804 echo "SMTP -> get_lines(): \$str is \"$str\"" . $this->CRLF . '<br />';947 $this->edebug("SMTP -> get_lines(): \$data was \"$data\"" . $this->CRLF . '<br />'); 948 $this->edebug("SMTP -> get_lines(): \$str is \"$str\"" . $this->CRLF . '<br />'); 805 949 } 806 950 $data .= $str; 807 951 if($this->do_debug >= 4) { 808 echo "SMTP -> get_lines(): \$data is \"$data\"" . $this->CRLF . '<br />';952 $this->edebug("SMTP -> get_lines(): \$data is \"$data\"" . $this->CRLF . '<br />'); 809 953 } 810 954 // if 4th character is a space, we are done reading, break the loop 811 955 if(substr($str,3,1) == " ") { break; } 956 // Timed-out? Log and break 957 $info = stream_get_meta_data($this->smtp_conn); 958 if ($info['timed_out']) { 959 if($this->do_debug >= 4) { 960 $this->edebug("SMTP -> get_lines(): timed-out (" . $this->Timeout . " seconds) <br />"); 961 } 962 break; 963 } 964 // Now check if reads took too long 965 if ($endtime) { 966 if (time() > $endtime) { 967 if($this->do_debug >= 4) { 968 $this->edebug("SMTP -> get_lines(): timelimit reached (" . $this->Timelimit . " seconds) <br />"); 969 } 970 break; 971 } 972 } 812 973 } 813 974 return $data; 814 975 }