Changeset 19632
- Timestamp:
- 12/28/2011 12:59:13 PM (14 years ago)
- Location:
- trunk/wp-includes
- Files:
-
- 2 edited
-
class-phpmailer.php (modified) (56 diffs)
-
class-smtp.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/class-phpmailer.php
r18107 r19632 3 3 .---------------------------------------------------------------------------. 4 4 | Software: PHPMailer - PHP email class | 5 | Version: 5.1 | 6 | Contact: via sourceforge.net support pages (also www.worxware.com) | 7 | Info: http://phpmailer.sourceforge.net | 8 | Support: http://sourceforge.net/projects/phpmailer/ | 5 | Version: 5.2 | 6 | Site: https://code.google.com/a/apache-extras.org/p/phpmailer/ | 9 7 | ------------------------------------------------------------------------- | 10 | Admin: Andy Prevost (project admininistrator)|8 | Admin: Jim Jagielski (project admininistrator) | 11 9 | Authors: Andy Prevost (codeworxtech) codeworxtech@users.sourceforge.net | 12 10 | : Marcus Bointon (coolbru) coolbru@users.sourceforge.net | 11 | : Jim Jagielski (jimjag) jimjag@gmail.com | 13 12 | Founder: Brent R. Matzelle (original founder) | 13 | Copyright (c) 2010-2011, Jim Jagielski. All Rights Reserved. | 14 14 | Copyright (c) 2004-2009, Andy Prevost. All Rights Reserved. | 15 15 | Copyright (c) 2001-2003, Brent R. Matzelle | … … 20 20 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | 21 21 | FITNESS FOR A PARTICULAR PURPOSE. | 22 | ------------------------------------------------------------------------- |23 | We offer a number of paid services (www.worxware.com): |24 | - Web Hosting on highly optimized fast and secure servers |25 | - Technology Consulting |26 | - Oursourcing (highly qualified programmers and graphic designers) |27 22 '---------------------------------------------------------------------------' 28 23 */ … … 34 29 * @author Andy Prevost 35 30 * @author Marcus Bointon 31 * @author Jim Jagielski 32 * @copyright 2010 - 2011 Jim Jagielski 36 33 * @copyright 2004 - 2009 Andy Prevost 37 * @version $Id: class.phpmailer.php 4 47 2009-05-25 01:36:38Z codeworxtech$34 * @version $Id: class.phpmailer.php 450 2010-06-23 16:46:33Z coolbru $ 38 35 * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License 39 36 */ … … 118 115 */ 119 116 public $AltBody = ''; 117 118 /** 119 * Stores the complete compiled MIME message body. 120 * @var string 121 * @access protected 122 */ 123 protected $MIMEBody = ''; 124 125 /** 126 * Stores the complete compiled MIME message headers. 127 * @var string 128 * @access protected 129 */ 130 protected $MIMEHeader = ''; 120 131 121 132 /** … … 269 280 */ 270 281 public $DKIM_identity = ''; 282 283 /** 284 * Used with DKIM DNS Resource Record 285 * @var string 286 */ 287 public $DKIM_passphrase = ''; 271 288 272 289 /** … … 301 318 * @var string 302 319 */ 303 public $Version = '5.1'; 320 public $Version = '5.2'; 321 322 /** 323 * What to use in the X-Mailer header 324 * @var string 325 */ 326 public $XMailer = ''; 304 327 305 328 ///////////////////////////////////////////////// … … 307 330 ///////////////////////////////////////////////// 308 331 309 pr ivate$smtp = NULL;310 pr ivate$to = array();311 pr ivate$cc = array();312 pr ivate$bcc = array();313 pr ivate$ReplyTo = array();314 pr ivate$all_recipients = array();315 pr ivate$attachment = array();316 pr ivate$CustomHeader = array();317 pr ivate$message_type = '';318 pr ivate$boundary = array();319 protected $language = array();320 pr ivate$error_count = 0;321 pr ivate $sign_cert_file = "";322 pr ivate $sign_key_file = "";323 pr ivate $sign_key_pass = "";324 pr ivate$exceptions = false;332 protected $smtp = NULL; 333 protected $to = array(); 334 protected $cc = array(); 335 protected $bcc = array(); 336 protected $ReplyTo = array(); 337 protected $all_recipients = array(); 338 protected $attachment = array(); 339 protected $CustomHeader = array(); 340 protected $message_type = ''; 341 protected $boundary = array(); 342 protected $language = array(); 343 protected $error_count = 0; 344 protected $sign_cert_file = ''; 345 protected $sign_key_file = ''; 346 protected $sign_key_pass = ''; 347 protected $exceptions = false; 325 348 326 349 ///////////////////////////////////////////////// … … 448 471 * @param string $name 449 472 * @return boolean true on success, false if address already used or invalid in some way 450 * @access pr ivate451 */ 452 pr ivatefunction AddAnAddress($kind, $address, $name = '') {473 * @access protected 474 */ 475 protected function AddAnAddress($kind, $address, $name = '') { 453 476 if (!preg_match('/^(to|cc|bcc|ReplyTo)$/', $kind)) { 454 echo 'Invalid recipient array: ' . $kind; 477 $this->SetError($this->Lang('Invalid recipient array').': '.$kind); 478 if ($this->exceptions) { 479 throw new phpmailerException('Invalid recipient array: ' . $kind); 480 } 481 echo $this->Lang('Invalid recipient array').': '.$kind; 455 482 return false; 456 483 } … … 486 513 * @return boolean 487 514 */ 488 public function SetFrom($address, $name = '', $auto=1) {515 public function SetFrom($address, $name = '', $auto = 1) { 489 516 $address = trim($address); 490 517 $name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim … … 545 572 public function Send() { 546 573 try { 574 if(!$this->PreSend()) return false; 575 return $this->PostSend(); 576 } catch (phpmailerException $e) { 577 $this->SetError($e->getMessage()); 578 if ($this->exceptions) { 579 throw $e; 580 } 581 return false; 582 } 583 } 584 585 protected function PreSend() { 586 try { 547 587 if ((count($this->to) + count($this->cc) + count($this->bcc)) < 1) { 548 588 throw new phpmailerException($this->Lang('provide_address'), self::STOP_CRITICAL); … … 556 596 $this->error_count = 0; // reset errors 557 597 $this->SetMessageType(); 558 $header = $this->CreateHeader(); 559 $body = $this->CreateBody(); 560 598 //Refuse to send an empty message 561 599 if (empty($this->Body)) { 562 600 throw new phpmailerException($this->Lang('empty_message'), self::STOP_CRITICAL); 563 601 } 564 602 603 $this->MIMEHeader = $this->CreateHeader(); 604 $this->MIMEBody = $this->CreateBody(); 605 606 565 607 // digitally sign with DKIM if enabled 566 608 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; 569 } 570 609 $header_dkim = $this->DKIM_Add($this->MIMEHeader, $this->EncodeHeader($this->SecureHeader($this->Subject)), $this->MIMEBody); 610 $this->MIMEHeader = str_replace("\r\n", "\n", $header_dkim) . $this->MIMEHeader; 611 } 612 613 return true; 614 } catch (phpmailerException $e) { 615 $this->SetError($e->getMessage()); 616 if ($this->exceptions) { 617 throw $e; 618 } 619 return false; 620 } 621 } 622 623 protected function PostSend() { 624 try { 571 625 // Choose the mailer and send through it 572 626 switch($this->Mailer) { 573 627 case 'sendmail': 574 return $this->SendmailSend($ header, $body);628 return $this->SendmailSend($this->MIMEHeader, $this->MIMEBody); 575 629 case 'smtp': 576 return $this->SmtpSend($ header, $body);630 return $this->SmtpSend($this->MIMEHeader, $this->MIMEBody); 577 631 default: 578 return $this->MailSend($ header, $body);632 return $this->MailSend($this->MIMEHeader, $this->MIMEBody); 579 633 } 580 634 … … 613 667 // implement call back function if it exists 614 668 $isSent = ($result == 0) ? 1 : 0; 615 $this->doCallback($isSent, $val,$this->cc,$this->bcc,$this->Subject,$body);669 $this->doCallback($isSent, $val, $this->cc, $this->bcc, $this->Subject, $body); 616 670 if($result != 0) { 617 671 throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL); … … 627 681 // implement call back function if it exists 628 682 $isSent = ($result == 0) ? 1 : 0; 629 $this->doCallback($isSent, $this->to,$this->cc,$this->bcc,$this->Subject,$body);683 $this->doCallback($isSent, $this->to, $this->cc, $this->bcc, $this->Subject, $body); 630 684 if($result != 0) { 631 685 throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL); … … 649 703 $to = implode(', ', $toArr); 650 704 651 $params = sprintf("-oi -f %s", $this->Sender); 652 if ($this->Sender != '' && strlen(ini_get('safe_mode'))< 1) { 705 if (empty($this->Sender)) { 706 $params = "-oi -f %s"; 707 } else { 708 $params = sprintf("-oi -f %s", $this->Sender); 709 } 710 if ($this->Sender != '' and !ini_get('safe_mode')) { 653 711 $old_from = ini_get('sendmail_from'); 654 712 ini_set('sendmail_from', $this->Sender); … … 658 716 // implement call back function if it exists 659 717 $isSent = ($rt == 1) ? 1 : 0; 660 $this->doCallback($isSent, $val,$this->cc,$this->bcc,$this->Subject,$body);718 $this->doCallback($isSent, $val, $this->cc, $this->bcc, $this->Subject, $body); 661 719 } 662 720 } else { … … 664 722 // implement call back function if it exists 665 723 $isSent = ($rt == 1) ? 1 : 0; 666 $this->doCallback($isSent, $to,$this->cc,$this->bcc,$this->Subject,$body);724 $this->doCallback($isSent, $to, $this->cc, $this->bcc, $this->Subject, $body); 667 725 } 668 726 } else { … … 672 730 // implement call back function if it exists 673 731 $isSent = ($rt == 1) ? 1 : 0; 674 $this->doCallback($isSent, $val,$this->cc,$this->bcc,$this->Subject,$body);732 $this->doCallback($isSent, $val, $this->cc, $this->bcc, $this->Subject, $body); 675 733 } 676 734 } else { … … 678 736 // implement call back function if it exists 679 737 $isSent = ($rt == 1) ? 1 : 0; 680 $this->doCallback($isSent, $to,$this->cc,$this->bcc,$this->Subject,$body);738 $this->doCallback($isSent, $to, $this->cc, $this->bcc, $this->Subject, $body); 681 739 } 682 740 } … … 700 758 */ 701 759 protected function SmtpSend($header, $body) { 702 require_once $this->PluginDir . 'class -smtp.php';760 require_once $this->PluginDir . 'class.smtp.php'; 703 761 $bad_rcpt = array(); 704 762 … … 717 775 // implement call back function if it exists 718 776 $isSent = 0; 719 $this->doCallback($isSent, $to[0],'','',$this->Subject,$body);777 $this->doCallback($isSent, $to[0], '', '', $this->Subject, $body); 720 778 } else { 721 779 // implement call back function if it exists 722 780 $isSent = 1; 723 $this->doCallback($isSent, $to[0],'','',$this->Subject,$body);781 $this->doCallback($isSent, $to[0], '', '', $this->Subject, $body); 724 782 } 725 783 } … … 729 787 // implement call back function if it exists 730 788 $isSent = 0; 731 $this->doCallback($isSent, '',$cc[0],'',$this->Subject,$body);789 $this->doCallback($isSent, '', $cc[0], '', $this->Subject, $body); 732 790 } else { 733 791 // implement call back function if it exists 734 792 $isSent = 1; 735 $this->doCallback($isSent, '',$cc[0],'',$this->Subject,$body);793 $this->doCallback($isSent, '', $cc[0], '', $this->Subject, $body); 736 794 } 737 795 } … … 741 799 // implement call back function if it exists 742 800 $isSent = 0; 743 $this->doCallback($isSent, '','',$bcc[0],$this->Subject,$body);801 $this->doCallback($isSent, '', '', $bcc[0], $this->Subject, $body); 744 802 } else { 745 803 // implement call back function if it exists 746 804 $isSent = 1; 747 $this->doCallback($isSent, '','',$bcc[0],$this->Subject,$body);805 $this->doCallback($isSent, '', '', $bcc[0], $this->Subject, $body); 748 806 } 749 807 } … … 943 1001 $line = explode($this->LE, $message); 944 1002 $message = ''; 945 for ($i =0 ;$i < count($line); $i++) {1003 for ($i = 0 ;$i < count($line); $i++) { 946 1004 $line_part = explode(' ', $line[$i]); 947 1005 $buf = ''; … … 1057 1115 switch($this->message_type) { 1058 1116 case 'alt': 1059 case 'alt_attachments': 1117 case 'alt_inline': 1118 case 'alt_attach': 1119 case 'alt_inline_attach': 1060 1120 $this->AltBody = $this->WrapText($this->AltBody, $this->WordWrap); 1061 1121 break; … … 1078 1138 $this->boundary[1] = 'b1_' . $uniq_id; 1079 1139 $this->boundary[2] = 'b2_' . $uniq_id; 1140 $this->boundary[3] = 'b3_' . $uniq_id; 1080 1141 1081 1142 $result .= $this->HeaderLine('Date', self::RFCDate()); … … 1126 1187 1127 1188 if($this->MessageID != '') { 1128 $result .= $this->HeaderLine('Message-ID', $this->MessageID);1189 $result .= $this->HeaderLine('Message-ID', $this->MessageID); 1129 1190 } else { 1130 1191 $result .= sprintf("Message-ID: <%s@%s>%s", $uniq_id, $this->ServerHostname(), $this->LE); 1131 1192 } 1132 1193 $result .= $this->HeaderLine('X-Priority', $this->Priority); 1133 $result .= $this->HeaderLine('X-Mailer', 'PHPMailer '.$this->Version.' (phpmailer.sourceforge.net)'); 1194 if($this->XMailer) { 1195 $result .= $this->HeaderLine('X-Mailer', $this->XMailer); 1196 } else { 1197 $result .= $this->HeaderLine('X-Mailer', 'PHPMailer '.$this->Version.' (http://code.google.com/a/apache-extras.org/p/phpmailer/)'); 1198 } 1134 1199 1135 1200 if($this->ConfirmReadingTo != '') { … … 1159 1224 case 'plain': 1160 1225 $result .= $this->HeaderLine('Content-Transfer-Encoding', $this->Encoding); 1161 $result .= sprintf("Content-Type: %s; charset=\"%s\"", $this->ContentType, $this->CharSet);1226 $result .= $this->TextLine('Content-Type: '.$this->ContentType.'; charset="'.$this->CharSet.'"'); 1162 1227 break; 1163 case 'attachments': 1164 case 'alt_attachments': 1165 if($this->InlineImageExists()){ 1166 $result .= sprintf("Content-Type: %s;%s\ttype=\"text/html\";%s\tboundary=\"%s\"%s", 'multipart/related', $this->LE, $this->LE, $this->boundary[1], $this->LE); 1167 } else { 1168 $result .= $this->HeaderLine('Content-Type', 'multipart/mixed;'); 1169 $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"'); 1170 } 1228 case 'inline': 1229 $result .= $this->HeaderLine('Content-Type', 'multipart/related;'); 1230 $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"'); 1231 break; 1232 case 'attach': 1233 case 'inline_attach': 1234 case 'alt_attach': 1235 case 'alt_inline_attach': 1236 $result .= $this->HeaderLine('Content-Type', 'multipart/mixed;'); 1237 $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"'); 1171 1238 break; 1172 1239 case 'alt': 1240 case 'alt_inline': 1173 1241 $result .= $this->HeaderLine('Content-Type', 'multipart/alternative;'); 1174 1242 $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"'); … … 1198 1266 1199 1267 switch($this->message_type) { 1268 case 'plain': 1269 $body .= $this->EncodeString($this->Body, $this->Encoding); 1270 break; 1271 case 'inline': 1272 $body .= $this->GetBoundary($this->boundary[1], '', '', ''); 1273 $body .= $this->EncodeString($this->Body, $this->Encoding); 1274 $body .= $this->LE.$this->LE; 1275 $body .= $this->AttachAll("inline", $this->boundary[1]); 1276 break; 1277 case 'attach': 1278 $body .= $this->GetBoundary($this->boundary[1], '', '', ''); 1279 $body .= $this->EncodeString($this->Body, $this->Encoding); 1280 $body .= $this->LE.$this->LE; 1281 $body .= $this->AttachAll("attachment", $this->boundary[1]); 1282 break; 1283 case 'inline_attach': 1284 $body .= $this->TextLine("--" . $this->boundary[1]); 1285 $body .= $this->HeaderLine('Content-Type', 'multipart/related;'); 1286 $body .= $this->TextLine("\tboundary=\"" . $this->boundary[2] . '"'); 1287 $body .= $this->LE; 1288 $body .= $this->GetBoundary($this->boundary[2], '', '', ''); 1289 $body .= $this->EncodeString($this->Body, $this->Encoding); 1290 $body .= $this->LE.$this->LE; 1291 $body .= $this->AttachAll("inline", $this->boundary[2]); 1292 $body .= $this->LE; 1293 $body .= $this->AttachAll("attachment", $this->boundary[1]); 1294 break; 1200 1295 case 'alt': 1201 1296 $body .= $this->GetBoundary($this->boundary[1], '', 'text/plain', ''); … … 1207 1302 $body .= $this->EndBoundary($this->boundary[1]); 1208 1303 break; 1209 case 'plain': 1210 $body .= $this->EncodeString($this->Body, $this->Encoding); 1211 break; 1212 case 'attachments': 1213 $body .= $this->GetBoundary($this->boundary[1], '', '', ''); 1214 $body .= $this->EncodeString($this->Body, $this->Encoding); 1215 $body .= $this->LE; 1216 $body .= $this->AttachAll(); 1217 break; 1218 case 'alt_attachments': 1219 $body .= sprintf("--%s%s", $this->boundary[1], $this->LE); 1220 $body .= sprintf("Content-Type: %s;%s" . "\tboundary=\"%s\"%s", 'multipart/alternative', $this->LE, $this->boundary[2], $this->LE.$this->LE); 1221 $body .= $this->GetBoundary($this->boundary[2], '', 'text/plain', '') . $this->LE; // Create text body 1304 case 'alt_inline': 1305 $body .= $this->GetBoundary($this->boundary[1], '', 'text/plain', ''); 1222 1306 $body .= $this->EncodeString($this->AltBody, $this->Encoding); 1223 1307 $body .= $this->LE.$this->LE; 1224 $body .= $this->GetBoundary($this->boundary[2], '', 'text/html', '') . $this->LE; // Create the HTML body 1308 $body .= $this->TextLine("--" . $this->boundary[1]); 1309 $body .= $this->HeaderLine('Content-Type', 'multipart/related;'); 1310 $body .= $this->TextLine("\tboundary=\"" . $this->boundary[2] . '"'); 1311 $body .= $this->LE; 1312 $body .= $this->GetBoundary($this->boundary[2], '', 'text/html', ''); 1313 $body .= $this->EncodeString($this->Body, $this->Encoding); 1314 $body .= $this->LE.$this->LE; 1315 $body .= $this->AttachAll("inline", $this->boundary[2]); 1316 $body .= $this->LE; 1317 $body .= $this->EndBoundary($this->boundary[1]); 1318 break; 1319 case 'alt_attach': 1320 $body .= $this->TextLine("--" . $this->boundary[1]); 1321 $body .= $this->HeaderLine('Content-Type', 'multipart/alternative;'); 1322 $body .= $this->TextLine("\tboundary=\"" . $this->boundary[2] . '"'); 1323 $body .= $this->LE; 1324 $body .= $this->GetBoundary($this->boundary[2], '', 'text/plain', ''); 1325 $body .= $this->EncodeString($this->AltBody, $this->Encoding); 1326 $body .= $this->LE.$this->LE; 1327 $body .= $this->GetBoundary($this->boundary[2], '', 'text/html', ''); 1225 1328 $body .= $this->EncodeString($this->Body, $this->Encoding); 1226 1329 $body .= $this->LE.$this->LE; 1227 1330 $body .= $this->EndBoundary($this->boundary[2]); 1228 $body .= $this->AttachAll(); 1331 $body .= $this->LE; 1332 $body .= $this->AttachAll("attachment", $this->boundary[1]); 1333 break; 1334 case 'alt_inline_attach': 1335 $body .= $this->TextLine("--" . $this->boundary[1]); 1336 $body .= $this->HeaderLine('Content-Type', 'multipart/alternative;'); 1337 $body .= $this->TextLine("\tboundary=\"" . $this->boundary[2] . '"'); 1338 $body .= $this->LE; 1339 $body .= $this->GetBoundary($this->boundary[2], '', 'text/plain', ''); 1340 $body .= $this->EncodeString($this->AltBody, $this->Encoding); 1341 $body .= $this->LE.$this->LE; 1342 $body .= $this->TextLine("--" . $this->boundary[2]); 1343 $body .= $this->HeaderLine('Content-Type', 'multipart/related;'); 1344 $body .= $this->TextLine("\tboundary=\"" . $this->boundary[3] . '"'); 1345 $body .= $this->LE; 1346 $body .= $this->GetBoundary($this->boundary[3], '', 'text/html', ''); 1347 $body .= $this->EncodeString($this->Body, $this->Encoding); 1348 $body .= $this->LE.$this->LE; 1349 $body .= $this->AttachAll("inline", $this->boundary[3]); 1350 $body .= $this->LE; 1351 $body .= $this->EndBoundary($this->boundary[2]); 1352 $body .= $this->LE; 1353 $body .= $this->AttachAll("attachment", $this->boundary[1]); 1229 1354 break; 1230 1355 } … … 1259 1384 /** 1260 1385 * Returns the start of a message boundary. 1261 * @access private 1262 */ 1263 private function GetBoundary($boundary, $charSet, $contentType, $encoding) { 1386 * @access protected 1387 * @return string 1388 */ 1389 protected function GetBoundary($boundary, $charSet, $contentType, $encoding) { 1264 1390 $result = ''; 1265 1391 if($charSet == '') { … … 1273 1399 } 1274 1400 $result .= $this->TextLine('--' . $boundary); 1275 $result .= sprintf("Content-Type: %s; charset =\"%s\"", $contentType, $charSet);1401 $result .= sprintf("Content-Type: %s; charset=\"%s\"", $contentType, $charSet); 1276 1402 $result .= $this->LE; 1277 1403 $result .= $this->HeaderLine('Content-Transfer-Encoding', $encoding); … … 1283 1409 /** 1284 1410 * Returns the end of a message boundary. 1285 * @access private 1286 */ 1287 private function EndBoundary($boundary) { 1411 * @access protected 1412 * @return string 1413 */ 1414 protected function EndBoundary($boundary) { 1288 1415 return $this->LE . '--' . $boundary . '--' . $this->LE; 1289 1416 } … … 1291 1418 /** 1292 1419 * Sets the message type. 1293 * @access pr ivate1420 * @access protected 1294 1421 * @return void 1295 1422 */ 1296 private function SetMessageType() { 1297 if(count($this->attachment) < 1 && strlen($this->AltBody) < 1) { 1298 $this->message_type = 'plain'; 1299 } else { 1300 if(count($this->attachment) > 0) { 1301 $this->message_type = 'attachments'; 1302 } 1303 if(strlen($this->AltBody) > 0 && count($this->attachment) < 1) { 1304 $this->message_type = 'alt'; 1305 } 1306 if(strlen($this->AltBody) > 0 && count($this->attachment) > 0) { 1307 $this->message_type = 'alt_attachments'; 1308 } 1309 } 1423 protected function SetMessageType() { 1424 $this->message_type = array(); 1425 if($this->AlternativeExists()) $this->message_type[] = "alt"; 1426 if($this->InlineImageExists()) $this->message_type[] = "inline"; 1427 if($this->AttachmentExists()) $this->message_type[] = "attach"; 1428 $this->message_type = implode("_", $this->message_type); 1429 if($this->message_type == "") $this->message_type = "plain"; 1310 1430 } 1311 1431 … … 1387 1507 * Attaches all fs, string, and binary attachments to the message. 1388 1508 * Returns an empty string on failure. 1389 * @access pr ivate1509 * @access protected 1390 1510 * @return string 1391 1511 */ 1392 pr ivate function AttachAll() {1512 protected function AttachAll($disposition_type, $boundary) { 1393 1513 // Return text of body 1394 1514 $mime = array(); … … 1398 1518 // Add all attachments 1399 1519 foreach ($this->attachment as $attachment) { 1400 // Check for string attachment 1401 $bString = $attachment[5]; 1402 if ($bString) { 1403 $string = $attachment[0]; 1404 } else { 1405 $path = $attachment[0]; 1406 } 1407 1408 if (in_array($attachment[0], $incl)) { continue; } 1409 $filename = $attachment[1]; 1410 $name = $attachment[2]; 1411 $encoding = $attachment[3]; 1412 $type = $attachment[4]; 1413 $disposition = $attachment[6]; 1414 $cid = $attachment[7]; 1415 $incl[] = $attachment[0]; 1416 if ( $disposition == 'inline' && isset($cidUniq[$cid]) ) { continue; } 1417 $cidUniq[$cid] = true; 1418 1419 $mime[] = sprintf("--%s%s", $this->boundary[1], $this->LE); 1420 $mime[] = sprintf("Content-Type: %s; name=\"%s\"%s", $type, $this->EncodeHeader($this->SecureHeader($name)), $this->LE); 1421 $mime[] = sprintf("Content-Transfer-Encoding: %s%s", $encoding, $this->LE); 1422 1423 if($disposition == 'inline') { 1424 $mime[] = sprintf("Content-ID: <%s>%s", $cid, $this->LE); 1425 } 1426 1427 $mime[] = sprintf("Content-Disposition: %s; filename=\"%s\"%s", $disposition, $this->EncodeHeader($this->SecureHeader($name)), $this->LE.$this->LE); 1428 1429 // Encode as string attachment 1430 if($bString) { 1431 $mime[] = $this->EncodeString($string, $encoding); 1432 if($this->IsError()) { 1433 return ''; 1520 // CHECK IF IT IS A VALID DISPOSITION_FILTER 1521 if($attachment[6] == $disposition_type) { 1522 // Check for string attachment 1523 $bString = $attachment[5]; 1524 if ($bString) { 1525 $string = $attachment[0]; 1526 } else { 1527 $path = $attachment[0]; 1434 1528 } 1435 $mime[] = $this->LE.$this->LE; 1436 } else { 1437 $mime[] = $this->EncodeFile($path, $encoding); 1438 if($this->IsError()) { 1439 return ''; 1529 1530 $inclhash = md5(serialize($attachment)); 1531 if (in_array($inclhash, $incl)) { continue; } 1532 $incl[] = $inclhash; 1533 $filename = $attachment[1]; 1534 $name = $attachment[2]; 1535 $encoding = $attachment[3]; 1536 $type = $attachment[4]; 1537 $disposition = $attachment[6]; 1538 $cid = $attachment[7]; 1539 if ( $disposition == 'inline' && isset($cidUniq[$cid]) ) { continue; } 1540 $cidUniq[$cid] = true; 1541 1542 $mime[] = sprintf("--%s%s", $boundary, $this->LE); 1543 $mime[] = sprintf("Content-Type: %s; name=\"%s\"%s", $type, $this->EncodeHeader($this->SecureHeader($name)), $this->LE); 1544 $mime[] = sprintf("Content-Transfer-Encoding: %s%s", $encoding, $this->LE); 1545 1546 if($disposition == 'inline') { 1547 $mime[] = sprintf("Content-ID: <%s>%s", $cid, $this->LE); 1440 1548 } 1441 $mime[] = $this->LE.$this->LE; 1442 } 1443 } 1444 1445 $mime[] = sprintf("--%s--%s", $this->boundary[1], $this->LE); 1446 1447 return join('', $mime); 1549 1550 $mime[] = sprintf("Content-Disposition: %s; filename=\"%s\"%s", $disposition, $this->EncodeHeader($this->SecureHeader($name)), $this->LE.$this->LE); 1551 1552 // Encode as string attachment 1553 if($bString) { 1554 $mime[] = $this->EncodeString($string, $encoding); 1555 if($this->IsError()) { 1556 return ''; 1557 } 1558 $mime[] = $this->LE.$this->LE; 1559 } else { 1560 $mime[] = $this->EncodeFile($path, $encoding); 1561 if($this->IsError()) { 1562 return ''; 1563 } 1564 $mime[] = $this->LE.$this->LE; 1565 } 1566 } 1567 } 1568 1569 $mime[] = sprintf("--%s--%s", $boundary, $this->LE); 1570 1571 return implode("", $mime); 1448 1572 } 1449 1573 … … 1454 1578 * @param string $encoding The encoding to use; one of 'base64', '7bit', '8bit', 'binary', 'quoted-printable' 1455 1579 * @see EncodeFile() 1456 * @access pr ivate1580 * @access protected 1457 1581 * @return string 1458 1582 */ 1459 pr ivatefunction EncodeFile($path, $encoding = 'base64') {1583 protected function EncodeFile($path, $encoding = 'base64') { 1460 1584 try { 1461 1585 if (!is_readable($path)) { … … 1467 1591 } 1468 1592 } 1469 if ( PHP_VERSION < 6) {1593 if (version_compare(PHP_VERSION, '5.3.0', '<')) { 1470 1594 $magic_quotes = get_magic_quotes_runtime(); 1471 1595 set_magic_quotes_runtime(0); … … 1473 1597 $file_buffer = file_get_contents($path); 1474 1598 $file_buffer = $this->EncodeString($file_buffer, $encoding); 1475 if (PHP_VERSION < 6) { set_magic_quotes_runtime($magic_quotes); } 1599 if (version_compare(PHP_VERSION, '5.3.0', '<')) { 1600 set_magic_quotes_runtime($magic_quotes); 1601 } 1476 1602 return $file_buffer; 1477 1603 } catch (Exception $e) { … … 1489 1615 * @return string 1490 1616 */ 1491 public function EncodeString ($str, $encoding = 'base64') {1617 public function EncodeString($str, $encoding = 'base64') { 1492 1618 $encoded = ''; 1493 1619 switch(strtolower($encoding)) { … … 1638 1764 */ 1639 1765 public function EncodeQPphp( $input = '', $line_max = 76, $space_conv = false) { 1640 $hex = array('0', '1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');1766 $hex = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'); 1641 1767 $lines = preg_split('/(?:\r\n|\r|\n)/', $input); 1642 1768 $eol = "\r\n"; … … 1719 1845 * @return string 1720 1846 */ 1721 public function EncodeQ ($str, $position = 'text') {1847 public function EncodeQ($str, $position = 'text') { 1722 1848 // There should not be any EOL in the string 1723 1849 $encoded = preg_replace('/[\r\n]*/', '', $str); … … 1734 1860 //TODO using /e (equivalent to eval()) is probably not a good idea 1735 1861 $encoded = preg_replace('/([\000-\011\013\014\016-\037\075\077\137\177-\377])/e', 1736 "'='.sprintf('%02X', ord('\\1'))", $encoded);1862 "'='.sprintf('%02X', ord(stripslashes('\\1')))", $encoded); 1737 1863 break; 1738 1864 } … … 1808 1934 } 1809 1935 1936 public function AddStringEmbeddedImage($string, $cid, $filename = '', $encoding = 'base64', $type = 'application/octet-stream') { 1937 // Append to $attachment array 1938 $this->attachment[] = array( 1939 0 => $string, 1940 1 => $filename, 1941 2 => basename($filename), 1942 3 => $encoding, 1943 4 => $type, 1944 5 => true, // isStringAttachment 1945 6 => 'inline', 1946 7 => $cid 1947 ); 1948 } 1949 1810 1950 /** 1811 1951 * Returns true if an inline attachment is present. … … 1820 1960 } 1821 1961 return false; 1962 } 1963 1964 public function AttachmentExists() { 1965 foreach($this->attachment as $attachment) { 1966 if ($attachment[6] == 'attachment') { 1967 return true; 1968 } 1969 } 1970 return false; 1971 } 1972 1973 public function AlternativeExists() { 1974 return strlen($this->AltBody)>0; 1822 1975 } 1823 1976 … … 1934 2087 /** 1935 2088 * Returns the server hostname or 'localhost.localdomain' if unknown. 1936 * @access pr ivate2089 * @access protected 1937 2090 * @return string 1938 2091 */ 1939 pr ivatefunction ServerHostname() {2092 protected function ServerHostname() { 1940 2093 if (!empty($this->Hostname)) { 1941 2094 $result = $this->Hostname; … … 1951 2104 /** 1952 2105 * Returns a message in the appropriate language. 1953 * @access pr ivate2106 * @access protected 1954 2107 * @return string 1955 2108 */ 1956 pr ivatefunction Lang($key) {2109 protected function Lang($key) { 1957 2110 if(count($this->language) < 1) { 1958 2111 $this->SetLanguage('en'); // set the default language … … 1977 2130 /** 1978 2131 * Changes every end of line from CR or LF to CRLF. 1979 * @access p rivate2132 * @access public 1980 2133 * @return string 1981 2134 */ 1982 p rivatefunction FixEOL($str) {2135 public function FixEOL($str) { 1983 2136 $str = str_replace("\r\n", "\n", $str); 1984 2137 $str = str_replace("\r", "\n", $str); … … 2006 2159 foreach($images[2] as $i => $url) { 2007 2160 // do not change urls for absolute images (thanks to corvuscorax) 2008 if (!preg_match('#^[A-z]+://#', $url)) {2161 if (!preg_match('#^[A-z]+://#', $url)) { 2009 2162 $filename = basename($url); 2010 2163 $directory = dirname($url); 2011 ($directory == '.') ?$directory='':'';2164 ($directory == '.') ? $directory='': ''; 2012 2165 $cid = 'cid:' . md5($filename); 2013 2166 $ext = pathinfo($filename, PATHINFO_EXTENSION); 2014 2167 $mimeType = self::_mime_types($ext); 2015 if ( strlen($basedir) > 1 && substr($basedir, -1) != '/') { $basedir .= '/'; }2016 if ( strlen($directory) > 1 && substr($directory, -1) != '/') { $directory .= '/'; }2017 if ( $this->AddEmbeddedImage($basedir.$directory.$filename, md5($filename), $filename, 'base64', $mimeType) ) {2168 if ( strlen($basedir) > 1 && substr($basedir, -1) != '/') { $basedir .= '/'; } 2169 if ( strlen($directory) > 1 && substr($directory, -1) != '/') { $directory .= '/'; } 2170 if ( $this->AddEmbeddedImage($basedir.$directory.$filename, md5($filename), $filename, 'base64', $mimeType) ) { 2018 2171 $message = preg_replace("/".$images[1][$i]."=\"".preg_quote($url, '/')."\"/Ui", $images[1][$i]."=\"".$cid."\"", $message); 2019 2172 } … … 2023 2176 $this->IsHTML(true); 2024 2177 $this->Body = $message; 2025 $textMsg = trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/s', '',$message)));2178 $textMsg = trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/s', '', $message))); 2026 2179 if (!empty($textMsg) && empty($this->AltBody)) { 2027 2180 $this->AltBody = html_entity_decode($textMsg); … … 2193 2346 */ 2194 2347 public function DKIM_QP($txt) { 2195 $tmp ="";2196 $line ="";2197 for ($i =0;$i<strlen($txt);$i++) {2198 $ord =ord($txt[$i]);2348 $tmp = ''; 2349 $line = ''; 2350 for ($i = 0; $i < strlen($txt); $i++) { 2351 $ord = ord($txt[$i]); 2199 2352 if ( ((0x21 <= $ord) && ($ord <= 0x3A)) || $ord == 0x3C || ((0x3E <= $ord) && ($ord <= 0x7E)) ) { 2200 $line .=$txt[$i];2353 $line .= $txt[$i]; 2201 2354 } else { 2202 $line .="=".sprintf("%02X",$ord);2355 $line .= "=".sprintf("%02X", $ord); 2203 2356 } 2204 2357 } … … 2214 2367 public function DKIM_Sign($s) { 2215 2368 $privKeyStr = file_get_contents($this->DKIM_private); 2216 if ($this->DKIM_passphrase !='') {2217 $privKey = openssl_pkey_get_private($privKeyStr, $this->DKIM_passphrase);2369 if ($this->DKIM_passphrase != '') { 2370 $privKey = openssl_pkey_get_private($privKeyStr, $this->DKIM_passphrase); 2218 2371 } else { 2219 2372 $privKey = $privKeyStr; … … 2231 2384 */ 2232 2385 public function DKIM_HeaderC($s) { 2233 $s =preg_replace("/\r\n\s+/"," ",$s);2234 $lines =explode("\r\n",$s);2235 foreach ($lines as $key =>$line) {2236 list($heading, $value)=explode(":",$line,2);2237 $heading =strtolower($heading);2238 $value =preg_replace("/\s+/"," ",$value) ; // Compress useless spaces2239 $lines[$key] =$heading.":".trim($value) ; // Don't forget to remove WSP around the value2240 } 2241 $s =implode("\r\n",$lines);2386 $s = preg_replace("/\r\n\s+/", " ", $s); 2387 $lines = explode("\r\n", $s); 2388 foreach ($lines as $key => $line) { 2389 list($heading, $value) = explode(":", $line, 2); 2390 $heading = strtolower($heading); 2391 $value = preg_replace("/\s+/", " ", $value) ; // Compress useless spaces 2392 $lines[$key] = $heading.":".trim($value) ; // Don't forget to remove WSP around the value 2393 } 2394 $s = implode("\r\n", $lines); 2242 2395 return $s; 2243 2396 } … … 2252 2405 if ($body == '') return "\r\n"; 2253 2406 // stabilize line endings 2254 $body =str_replace("\r\n","\n",$body);2255 $body =str_replace("\n","\r\n",$body);2407 $body = str_replace("\r\n", "\n", $body); 2408 $body = str_replace("\n", "\r\n", $body); 2256 2409 // END stabilize line endings 2257 while (substr($body, strlen($body)-4,4) == "\r\n\r\n") {2258 $body =substr($body,0,strlen($body)-2);2410 while (substr($body, strlen($body) - 4, 4) == "\r\n\r\n") { 2411 $body = substr($body, 0, strlen($body) - 2); 2259 2412 } 2260 2413 return $body; … … 2269 2422 * @param string $body Body 2270 2423 */ 2271 public function DKIM_Add($headers_line, $subject,$body) {2424 public function DKIM_Add($headers_line, $subject, $body) { 2272 2425 $DKIMsignatureType = 'rsa-sha1'; // Signature & hash algorithms 2273 2426 $DKIMcanonicalization = 'relaxed/simple'; // Canonicalization of header/body … … 2275 2428 $DKIMtime = time() ; // Signature Timestamp = seconds since 00:00:00 - Jan 1, 1970 (UTC time zone) 2276 2429 $subject_header = "Subject: $subject"; 2277 $headers = explode( "\r\n",$headers_line);2430 $headers = explode($this->LE, $headers_line); 2278 2431 foreach($headers as $header) { 2279 if (strpos($header, 'From:') === 0) {2280 $from_header =$header;2281 } elseif (strpos($header, 'To:') === 0) {2282 $to_header =$header;2283 } 2284 } 2285 $from = str_replace('|', '=7C',$this->DKIM_QP($from_header));2286 $to = str_replace('|', '=7C',$this->DKIM_QP($to_header));2287 $subject = str_replace('|', '=7C',$this->DKIM_QP($subject_header)) ; // Copied header fields (dkim-quoted-printable2432 if (strpos($header, 'From:') === 0) { 2433 $from_header = $header; 2434 } elseif (strpos($header, 'To:') === 0) { 2435 $to_header = $header; 2436 } 2437 } 2438 $from = str_replace('|', '=7C', $this->DKIM_QP($from_header)); 2439 $to = str_replace('|', '=7C', $this->DKIM_QP($to_header)); 2440 $subject = str_replace('|', '=7C', $this->DKIM_QP($subject_header)) ; // Copied header fields (dkim-quoted-printable 2288 2441 $body = $this->DKIM_BodyC($body); 2289 2442 $DKIMlen = strlen($body) ; // Length of body … … 2304 2457 } 2305 2458 2306 protected function doCallback($isSent, $to,$cc,$bcc,$subject,$body) {2459 protected function doCallback($isSent, $to, $cc, $bcc, $subject, $body) { 2307 2460 if (!empty($this->action_function) && function_exists($this->action_function)) { 2308 $params = array($isSent, $to,$cc,$bcc,$subject,$body);2309 call_user_func_array($this->action_function, $params);2461 $params = array($isSent, $to, $cc, $bcc, $subject, $body); 2462 call_user_func_array($this->action_function, $params); 2310 2463 } 2311 2464 } -
trunk/wp-includes/class-smtp.php
r17676 r19632 3 3 .---------------------------------------------------------------------------. 4 4 | Software: PHPMailer - PHP email class | 5 | Version: 5.1 | 6 | Contact: via sourceforge.net support pages (also www.codeworxtech.com) | 7 | Info: http://phpmailer.sourceforge.net | 8 | Support: http://sourceforge.net/projects/phpmailer/ | 5 | Version: 5.2 | 6 | Site: https://code.google.com/a/apache-extras.org/p/phpmailer/ | 9 7 | ------------------------------------------------------------------------- | 10 | Admin: Andy Prevost (project admininistrator)|8 | Admin: Jim Jagielski (project admininistrator) | 11 9 | Authors: Andy Prevost (codeworxtech) codeworxtech@users.sourceforge.net | 12 10 | : Marcus Bointon (coolbru) coolbru@users.sourceforge.net | 11 | : Jim Jagielski (jimjag) jimjag@gmail.com | 13 12 | Founder: Brent R. Matzelle (original founder) | 13 | Copyright (c) 2010-2011, Jim Jagielski. All Rights Reserved. | 14 14 | Copyright (c) 2004-2009, Andy Prevost. All Rights Reserved. | 15 15 | Copyright (c) 2001-2003, Brent R. Matzelle | … … 20 20 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | 21 21 | FITNESS FOR A PARTICULAR PURPOSE. | 22 | ------------------------------------------------------------------------- |23 | We offer a number of paid services (www.codeworxtech.com): |24 | - Web Hosting on highly optimized fast and secure servers |25 | - Technology Consulting |26 | - Oursourcing (highly qualified programmers and graphic designers) |27 22 '---------------------------------------------------------------------------' 28 23 */ … … 35 30 * @author Marcus Bointon 36 31 * @copyright 2004 - 2008 Andy Prevost 32 * @author Jim Jagielski 33 * @copyright 2010 - 2011 Jim Jagielski 37 34 * @license http://www.gnu.org/copyleft/lesser.html Distributed under the Lesser General Public License (LGPL) 38 * @version $Id: class.smtp.php 4 44 2009-05-05 11:22:26Z coolbru $35 * @version $Id: class.smtp.php 450 2010-06-23 16:46:33Z coolbru $ 39 36 */ 40 37 … … 71 68 */ 72 69 public $do_verp = false; 70 71 /** 72 * Sets the SMTP PHPMailer Version number 73 * @var string 74 */ 75 public $Version = '5.2'; 73 76 74 77 /////////////////////////////////////////////////
Note: See TracChangeset
for help on using the changeset viewer.