Changeset 4072 in subversion
- Timestamp:
- Oct 11, 2010 2:37:47 AM (3 years ago)
- File:
-
- 1 edited
-
trunk/roundcubemail/program/lib/Net/SMTP.php (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/roundcubemail/program/lib/Net/SMTP.php
r3339 r4072 505 505 * specified, the best supported method will be used. 506 506 * @param bool Flag indicating whether or not TLS should be attempted. 507 * @param string An optional authorization identifier. If specified, this 508 * identifier will be used as the authorization proxy. 507 509 * 508 510 * @return mixed Returns a PEAR_Error with an error message on any … … 511 513 * @since 1.0 512 514 */ 513 function auth($uid, $pwd , $method = '', $tls = true )515 function auth($uid, $pwd , $method = '', $tls = true, $authz = '') 514 516 { 515 517 /* We can only attempt a TLS connection if one has been requested, … … 559 561 switch ($method) { 560 562 case 'DIGEST-MD5': 561 $result = $this->_authDigest_MD5($uid, $pwd );563 $result = $this->_authDigest_MD5($uid, $pwd, $authz); 562 564 break; 563 565 … … 571 573 572 574 case 'PLAIN': 573 $result = $this->_authPlain($uid, $pwd );575 $result = $this->_authPlain($uid, $pwd, $authz); 574 576 break; 575 577 … … 592 594 * @param string The userid to authenticate as. 593 595 * @param string The password to authenticate with. 596 * @param string The optional authorization proxy identifier. 594 597 * 595 598 * @return mixed Returns a PEAR_Error with an error message on any … … 598 601 * @since 1.1.0 599 602 */ 600 function _authDigest_MD5($uid, $pwd )603 function _authDigest_MD5($uid, $pwd, $authz = '') 601 604 { 602 605 if (PEAR::isError($error = $this->_put('AUTH', 'DIGEST-MD5'))) { … … 615 618 $digest = &Auth_SASL::factory('digestmd5'); 616 619 $auth_str = base64_encode($digest->getResponse($uid, $pwd, $challenge, 617 $this->host, "smtp" ));620 $this->host, "smtp", $authz)); 618 621 619 622 if (PEAR::isError($error = $this->_put($auth_str))) { … … 726 729 * @param string The userid to authenticate as. 727 730 * @param string The password to authenticate with. 731 * @param string The optional authorization proxy identifier. 728 732 * 729 733 * @return mixed Returns a PEAR_Error with an error message on any … … 732 736 * @since 1.1.0 733 737 */ 734 function _authPlain($uid, $pwd )738 function _authPlain($uid, $pwd, $authz = '') 735 739 { 736 740 if (PEAR::isError($error = $this->_put('AUTH', 'PLAIN'))) { … … 746 750 } 747 751 748 $auth_str = base64_encode( chr(0) . $uid . chr(0) . $pwd);752 $auth_str = base64_encode($authz . chr(0) . $uid . chr(0) . $pwd); 749 753 750 754 if (PEAR::isError($error = $this->_put($auth_str))) { … … 970 974 } 971 975 } 972 973 /* Finally, send the DATA terminator sequence. */974 if (PEAR::isError($result = $this->_send("\r\n.\r\n"))) {975 return $result;976 }977 976 } else { 978 /* Just send the entire quoted string followed by the DATA 979 * terminator. */ 980 $this->quotedata($data); 981 if (PEAR::isError($result = $this->_send($data . "\r\n.\r\n"))) { 982 return $result; 983 } 977 /* 978 * Break up the data by sending one chunk (up to 512k) at a time. 979 * This approach reduces our peak memory usage. 980 */ 981 for ($offset = 0; $offset < $size;) { 982 $end = $offset + 512000; 983 984 /* 985 * Ensure we don't read beyond our data size or span multiple 986 * lines. quotedata() can't properly handle character data 987 * that's split across two line break boundaries. 988 */ 989 if ($end >= $size) { 990 $end = $size; 991 } else { 992 for (; $end < $size; $end++) { 993 if ($data[$end] != "\n") { 994 break; 995 } 996 } 997 } 998 999 /* Extract our chunk and run it through the quoting routine. */ 1000 $chunk = substr($data, $offset, $end - $offset); 1001 $this->quotedata($chunk); 1002 1003 /* If we run into a problem along the way, abort. */ 1004 if (PEAR::isError($result = $this->_send($chunk))) { 1005 return $result; 1006 } 1007 1008 /* Advance the offset to the end of this chunk. */ 1009 $offset = $end; 1010 } 1011 } 1012 1013 /* Finally, send the DATA terminator sequence. */ 1014 if (PEAR::isError($result = $this->_send("\r\n.\r\n"))) { 1015 return $result; 984 1016 } 985 1017
Note: See TracChangeset
for help on using the changeset viewer.
