Changeset 10572
- Timestamp:
- Jan 30, 2009, 12:55:31 PM (11 years ago)
- Location:
- OpenPNE3/branches/replace_mailer_library/lib/vendor/Zend
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
OpenPNE3/branches/replace_mailer_library/lib/vendor/Zend/Mail.php
r10571 r10572 17 17 * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) 18 18 * @license http://framework.zend.com/license/new-bsd New BSD License 19 * @version $Id: Mail.php 13 589 2009-01-10 13:04:25Z yoshida@zend.co.jp $19 * @version $Id: Mail.php 13804 2009-01-26 09:31:35Z yoshida@zend.co.jp $ 20 20 */ 21 21 … … 78 78 * @var string 79 79 */ 80 protected $_ encodingOfHeaders= Zend_Mime::ENCODING_QUOTEDPRINTABLE;80 protected $_headerEncoding = Zend_Mime::ENCODING_QUOTEDPRINTABLE; 81 81 82 82 /** … … 256 256 * @return string 257 257 */ 258 public function get EncodingOfHeaders()259 { 260 return $this->_ encodingOfHeaders;258 public function getHeaderEncoding() 259 { 260 return $this->_headerEncoding; 261 261 } 262 262 … … 268 268 * 269 269 */ 270 public function set EncodingOfHeaders($encoding)270 public function setHeaderEncoding($encoding) 271 271 { 272 272 $allowed = array( … … 281 281 throw new Zend_Mail_Exception('Invalid encoding "' . $encoding . '"'); 282 282 } 283 $this->_ encodingOfHeaders= $encoding;283 $this->_headerEncoding = $encoding; 284 284 285 285 return $this; … … 435 435 protected function _encodeHeader($value) 436 436 { 437 if (Zend_Mime::isPrintable($value)) { 438 return $value; 439 } elseif ($this->_encodingOfHeaders === Zend_Mime::ENCODING_QUOTEDPRINTABLE) { 440 $quotedValue = Zend_Mime::encodeQuotedPrintable($value); 441 $quotedValue = str_replace(array('?', ' ', '_'), array('=3F', '=20', '=5F'), $quotedValue); 442 return '=?' . $this->_charset . '?Q?' . $quotedValue . '?='; 443 } elseif ($this->_encodingOfHeaders === Zend_Mime::ENCODING_BASE64) { 444 return '=?' . $this->_charset . '?B?' . Zend_Mime::encodeBase64($value) . '?='; 445 } else { 446 /** 447 * @todo 7Bit and 8Bit is currently handled the same way. 448 */ 449 return $value; 450 } 437 if (Zend_Mime::isPrintable($value) === false) { 438 if ($this->getHeaderEncoding() === Zend_Mime::ENCODING_QUOTEDPRINTABLE) { 439 $value = Zend_Mime::encodeQuotedPrintableHeader($value, $this->getCharset(), Zend_Mime::LINELENGTH, Zend_Mime::LINEEND); 440 } else { 441 $value = Zend_Mime::encodeBase64Header($value, $this->getCharset(), Zend_Mime::LINELENGTH, Zend_Mime::LINEEND); 442 } 443 } 444 445 return $value; 451 446 } 452 447 … … 488 483 489 484 /** 490 * Add a recipient 491 * 485 * Helper function for adding a recipient and the corresponding header 486 * 487 * @param string $headerName 492 488 * @param string $email 493 * @param boolean $to 494 */ 495 protected function _addRecipient($email, $to = false) 496 { 489 * @param string $name 490 */ 491 protected function _addRecipientAndHeader($headerName, $email, $name) 492 { 493 $email = $this->_filterEmail($email); 494 $name = $this->_filterName($name); 497 495 // prevent duplicates 498 496 $this->_recipients[$email] = 1; 499 500 if ($to) { 501 $this->_to[] = $email; 502 } 503 } 504 505 /** 506 * Helper function for adding a recipient and the corresponding header 507 * 508 * @param string $headerName 509 * @param string $name 510 * @param string $email 511 */ 512 protected function _addRecipientAndHeader($headerName, $name, $email) 513 { 514 $name = $this->_filterName($name); 515 $email = $this->_filterEmail($email); 516 $this->_addRecipient($email, ('To' == $headerName) ? true : false); 517 if ($name !== '' && $name !== null && $name !== $email) { 518 $encodedName = $this->_encodeHeader($name); 519 if ($encodedName === $name && strpos($name, ',') !== false) { 520 $format = '"%s" <%s>'; 521 } else { 522 $format = '%s <%s>'; 523 } 524 $destination = sprintf($format, $encodedName, $email); 525 } else { 526 $destination = $email; 527 } 528 $this->_storeHeader($headerName, $destination, true); 497 $this->_storeHeader($headerName, $this->_formatAddress($email, $name), true); 529 498 } 530 499 … … 538 507 public function addTo($email, $name='') 539 508 { 540 $this->_addRecipientAndHeader('To', $name, $email); 509 $this->_addRecipientAndHeader('To', $email, $name); 510 $this->_to[] = $email; 541 511 return $this; 542 512 } … … 551 521 public function addCc($email, $name='') 552 522 { 553 $this->_addRecipientAndHeader('Cc', $ name, $email);523 $this->_addRecipientAndHeader('Cc', $email, $name); 554 524 return $this; 555 525 } … … 563 533 public function addBcc($email) 564 534 { 565 $this->_addRecipientAndHeader('Bcc', '', $email);535 $this->_addRecipientAndHeader('Bcc', $email, ''); 566 536 return $this; 567 537 } … … 608 578 $name = $this->_filterName($name); 609 579 $this->_from = $email; 610 if ($name !== null && $name !== $email) { 611 $encodedName = $this->_encodeHeader($name); 612 if ($encodedName === $name && strpos($name, ',') !== false) { 613 $format = '"%s" <%s>'; 614 } else { 615 $format = '%s <%s>'; 616 } 617 $from = sprintf($format, $encodedName, $email); 618 } else { 619 $from = $email; 620 } 621 $this->_storeHeader('From', $from, true); 580 $this->_storeHeader('From', $this->_formatAddress($email, $name), true); 622 581 } else { 623 582 /** … … 715 674 { 716 675 if ($this->_subject === null) { 717 $subject = strtr($subject,"\r\n\t",'???');676 $subject = $this->_filterOther($subject); 718 677 $this->_subject = $this->_encodeHeader($subject); 719 678 $this->_storeHeader('Subject', $this->_subject); … … 841 800 842 801 if ($this->_messageId === null) { 802 $id = $this->_filterOther($id); 843 803 $this->_messageId = $id; 844 804 $this->_storeHeader('Message-Id', $this->_messageId); … … 923 883 public function addHeader($name, $value, $append = false) 924 884 { 925 if (in_array(strtolower($name), array('to', 'cc', 'bcc', 'from', 'subject', 'return-path', 'date'))) { 885 $prohibit = array('to', 'cc', 'bcc', 'from', 'subject', 886 'return-path', 'date', 'message-id', 887 ); 888 if (in_array(strtolower($name), $prohibit)) { 926 889 /** 927 890 * @see Zend_Mail_Exception … … 931 894 } 932 895 933 $value = strtr($value,"\r\n\t",'???');896 $value = $this->_filterOther($value); 934 897 $value = $this->_encodeHeader($value); 935 898 $this->_storeHeader($name, $value, $append); … … 1012 975 ); 1013 976 1014 return strtr($name, $rule); 977 return trim(strtr($name, $rule)); 978 } 979 980 /** 981 * Filter of other data 982 * 983 * @param string $data 984 * @return string 985 */ 986 protected function _filterOther($data) 987 { 988 $rule = array("\r" => '', 989 "\n" => '', 990 "\t" => '', 991 ); 992 993 return strtr($data, $rule); 994 } 995 996 /** 997 * Formats e-mail address 998 * 999 * @param string $email 1000 * @param string $name 1001 * @return string 1002 */ 1003 protected function _formatAddress($email, $name) 1004 { 1005 if ($name === '' || $name === null || $name === $email) { 1006 return $email; 1007 } else { 1008 $encodedName = $this->_encodeHeader($name); 1009 if ($encodedName === $name && strpos($name, ',') !== false) { 1010 $format = '"%s" <%s>'; 1011 } else { 1012 $format = '%s <%s>'; 1013 } 1014 return sprintf($format, $encodedName, $email); 1015 } 1015 1016 } 1016 1017 -
OpenPNE3/branches/replace_mailer_library/lib/vendor/Zend/Mail/Part.php
r10569 r10572 17 17 * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) 18 18 * @license http://framework.zend.com/license/new-bsd New BSD License 19 * @version $Id: Part.php 1 2519 2008-11-10 18:41:24Z alexander$19 * @version $Id: Part.php 13591 2009-01-11 09:04:09Z beberlei $ 20 20 */ 21 21 … … 338 338 $lowerName = strtolower($name); 339 339 340 if ( !isset($this->_headers[$lowerName])) {340 if ($this->headerExists($name) == false) { 341 341 $lowerName = strtolower(preg_replace('%([a-z])([A-Z])%', '\1-\2', $name)); 342 if (!isset($this->_headers[$lowerName])) {342 if($this->headerExists($lowerName) == false) { 343 343 /** 344 344 * @see Zend_Mail_Exception 345 345 */ 346 346 require_once 'Zend/Mail/Exception.php'; 347 throw new Zend_Mail_Exception("no Header with Name $name found");347 throw new Zend_Mail_Exception("no Header with Name $name or $lowerName found"); 348 348 } 349 349 } … … 366 366 return $header; 367 367 } 368 369 /** 370 * Check wheater the Mail part has a specific header. 371 * 372 * @param string $name 373 * @return boolean 374 */ 375 public function headerExists($name) 376 { 377 $name = strtolower($name); 378 if(isset($this->_headers[$name])) { 379 return true; 380 } else { 381 return false; 382 } 383 } 368 384 369 385 /** … … 404 420 405 421 /** 422 * Isset magic method proxy to hasHeader 423 * 424 * This method is short syntax for Zend_Mail_Part::hasHeader($name); 425 * 426 * @see Zend_Mail_Part::hasHeader 427 * 428 * @param string 429 * @return boolean 430 */ 431 public function __isset($name) 432 { 433 return $this->headerExists($name); 434 } 435 436 /** 406 437 * magic method to get content of part 407 438 *
Note: See TracChangeset
for help on using the changeset viewer.