PEAR Net_SMTP updated to 1.8.0

Source: https://pear.php.net/package/Net_SMTP
Release date: 2017-04-06
This commit is contained in:
Mikael Nordfeldth 2017-07-10 12:53:13 +02:00
parent f025671b8a
commit 61876ed232

View File

@ -3,15 +3,33 @@
// +----------------------------------------------------------------------+ // +----------------------------------------------------------------------+
// | PHP Version 5 and 7 | // | PHP Version 5 and 7 |
// +----------------------------------------------------------------------+ // +----------------------------------------------------------------------+
// | Copyright (c) 1997-2015 Jon Parise and Chuck Hagenbuch | // | Copyright (c) 1997-2017 Jon Parise and Chuck Hagenbuch |
// +----------------------------------------------------------------------+ // | All rights reserved. |
// | This source file is subject to version 3.01 of the PHP license, | // | |
// | that is bundled with this package in the file LICENSE, and is | // | Redistribution and use in source and binary forms, with or without |
// | available at through the world-wide-web at | // | modification, are permitted provided that the following conditions |
// | http://www.php.net/license/3_01.txt. | // | are met: |
// | If you did not receive a copy of the PHP license and are unable to | // | |
// | obtain it through the world-wide-web, please send a note to | // | 1. Redistributions of source code must retain the above copyright |
// | license@php.net so we can mail you a copy immediately. | // | notice, this list of conditions and the following disclaimer. |
// | |
// | 2. Redistributions in binary form must reproduce the above copyright |
// | notice, this list of conditions and the following disclaimer in |
// | the documentation and/or other materials provided with the |
// | distribution. |
// | |
// | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
// | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
// | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
// | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
// | COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
// | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
// | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
// | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
// | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
// | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
// | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
// | POSSIBILITY OF SUCH DAMAGE. |
// +----------------------------------------------------------------------+ // +----------------------------------------------------------------------+
// | Authors: Chuck Hagenbuch <chuck@horde.org> | // | Authors: Chuck Hagenbuch <chuck@horde.org> |
// | Jon Parise <jon@php.net> | // | Jon Parise <jon@php.net> |
@ -29,6 +47,7 @@ require_once 'Net/Socket.php';
* @author Chuck Hagenbuch <chuck@horde.org> * @author Chuck Hagenbuch <chuck@horde.org>
* @author Jon Parise <jon@php.net> * @author Jon Parise <jon@php.net>
* @author Damian Alejandro Fernandez Sosa <damlists@cnba.uba.ar> * @author Damian Alejandro Fernandez Sosa <damlists@cnba.uba.ar>
* @license http://opensource.org/licenses/bsd-license.php BSD-2-Clause
* *
* @example basic.php A basic implementation of the Net_SMTP package. * @example basic.php A basic implementation of the Net_SMTP package.
*/ */
@ -701,7 +720,8 @@ class Net_SMTP
return $error; return $error;
} }
$digest = Auth_SASL::factory('digest-md5'); $auth_sasl = new Auth_SASL;
$digest = $auth_sasl->factory('digest-md5');
$challenge = base64_decode($this->arguments[0]); $challenge = base64_decode($this->arguments[0]);
$auth_str = base64_encode( $auth_str = base64_encode(
$digest->getResponse($uid, $pwd, $challenge, $this->host, "smtp", $authz) $digest->getResponse($uid, $pwd, $challenge, $this->host, "smtp", $authz)
@ -752,8 +772,9 @@ class Net_SMTP
return $error; return $error;
} }
$auth_sasl = new Auth_SASL;
$challenge = base64_decode($this->arguments[0]); $challenge = base64_decode($this->arguments[0]);
$cram = Auth_SASL::factory('cram-md5'); $cram = $auth_sasl->factory('cram-md5');
$auth_str = base64_encode($cram->getResponse($uid, $pwd, $challenge)); $auth_str = base64_encode($cram->getResponse($uid, $pwd, $challenge));
if (PEAR::isError($error = $this->put($auth_str))) { if (PEAR::isError($error = $this->put($auth_str))) {
@ -998,7 +1019,7 @@ class Net_SMTP
/* Start by considering the size of the optional headers string. We /* Start by considering the size of the optional headers string. We
* also account for the addition 4 character "\r\n\r\n" separator * also account for the addition 4 character "\r\n\r\n" separator
* sequence. */ * sequence. */
$size = (is_null($headers)) ? 0 : strlen($headers) + 4; $size = $headers_size = (is_null($headers)) ? 0 : strlen($headers) + 4;
if (is_resource($data)) { if (is_resource($data)) {
$stat = fstat($data); $stat = fstat($data);
@ -1034,6 +1055,9 @@ class Net_SMTP
if (PEAR::isError($result = $this->send($headers . "\r\n\r\n"))) { if (PEAR::isError($result = $this->send($headers . "\r\n\r\n"))) {
return $result; return $result;
} }
/* Subtract the headers size now that they've been sent. */
$size -= $headers_size;
} }
/* Now we can send the message body data. */ /* Now we can send the message body data. */