Commit 8479539b authored by Sebastian Kummer's avatar Sebastian Kummer

Merge pull request #581 in ZP/z-push from...

Merge pull request #581 in ZP/z-push from bugfix/ZP-1276-error-in-logging-when-sending-email to develop

* commit '2f5fc742':
  ZP-1276 Update Mail library. Released under the Affero GNU General Public License (AGPL) version 3.
  ZP-1276 Error in logging when sending email with imap backend. Released under the Affero GNU General Public License (AGPL) version 3.
parents 79012c94 2f5fc742
...@@ -2,31 +2,33 @@ ...@@ -2,31 +2,33 @@
/** /**
* internal PHP-mail() implementation of the PEAR Mail:: interface. * internal PHP-mail() implementation of the PEAR Mail:: interface.
* *
* PHP versions 4 and 5 * PHP version 5
* *
* LICENSE: * LICENSE:
* *
* Copyright (c) 2010 Chuck Hagenbuch * Copyright (c) 2010-2017, Chuck Hagenbuch
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
* *
* o Redistributions of source code must retain the above copyright * 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* o Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the following disclaimer in the * 2. Redistributions in binary form must reproduce the above copyright
* documentation and/or other materials provided with the distribution. * notice, this list of conditions and the following disclaimer in the
* o The names of the authors may not be used to endorse or promote * documentation and/or other materials provided with the distribution.
* products derived from this software without specific prior written *
* permission. * 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
...@@ -37,27 +39,27 @@ ...@@ -37,27 +39,27 @@
* @category Mail * @category Mail
* @package Mail * @package Mail
* @author Chuck Hagenbuch <chuck@horde.org> * @author Chuck Hagenbuch <chuck@horde.org>
* @copyright 2010 Chuck Hagenbuch * @copyright 2010-2017 Chuck Hagenbuch
* @license http://opensource.org/licenses/bsd-license.php New BSD License * @license http://opensource.org/licenses/BSD-3-Clause New BSD License
* @version CVS: $Id: mail.php 294747 2010-02-08 08:18:33Z clockwerx $ * @version CVS: $Id$
* @link http://pear.php.net/package/Mail/ * @link http://pear.php.net/package/Mail/
*/ */
/** /**
* Z-Push changes * Z-Push changes
* *
* removed PEAR dependency by implementing own raiseError() * removed PEAR dependency by implementing own raiseError()
* *
* Reference implementation used: * Reference implementation used:
* http://download.pear.php.net/package/Mail-1.2.0.tgz * http://download.pear.php.net/package/Mail-1.4.1.tgz
* *
* *
*/ */
/** /**
* internal PHP-mail() implementation of the PEAR Mail:: interface. * internal PHP-mail() implementation of the PEAR Mail:: interface.
* @package Mail * @package Mail
* @version $Revision: 294747 $ * @version $Revision$
*/ */
class Mail_mail extends Mail { class Mail_mail extends Mail {
...@@ -75,7 +77,7 @@ class Mail_mail extends Mail { ...@@ -75,7 +77,7 @@ class Mail_mail extends Mail {
* *
* @param array $params Extra arguments for the mail() function. * @param array $params Extra arguments for the mail() function.
*/ */
function __construct($params = null) public function __construct($params = null)
{ {
// The other mail implementations accept parameters as arrays. // The other mail implementations accept parameters as arrays.
// In the interest of being consistent, explode an array into // In the interest of being consistent, explode an array into
...@@ -120,10 +122,8 @@ class Mail_mail extends Mail { ...@@ -120,10 +122,8 @@ class Mail_mail extends Mail {
* @return mixed Returns true on success, or a PEAR_Error * @return mixed Returns true on success, or a PEAR_Error
* containing a descriptive error message on * containing a descriptive error message on
* failure. * failure.
*
* @access public
*/ */
function send($recipients, $headers, $body) public function send($recipients, $headers, $body)
{ {
if (!is_array($headers)) { if (!is_array($headers)) {
return Mail_mail::raiseError('$headers must be an array'); return Mail_mail::raiseError('$headers must be an array');
......
...@@ -6,27 +6,29 @@ ...@@ -6,27 +6,29 @@
* *
* LICENSE: * LICENSE:
* *
* Copyright (c) 2010, Chuck Hagenbuch * Copyright (c) 2010-2017, Chuck Hagenbuch & Jon Parise
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
* *
* o Redistributions of source code must retain the above copyright * 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* o Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the following disclaimer in the * 2. Redistributions in binary form must reproduce the above copyright
* documentation and/or other materials provided with the distribution. * notice, this list of conditions and the following disclaimer in the
* o The names of the authors may not be used to endorse or promote * documentation and/or other materials provided with the distribution.
* products derived from this software without specific prior written *
* permission. * 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
...@@ -38,19 +40,19 @@ ...@@ -38,19 +40,19 @@
* @package Mail * @package Mail
* @author Jon Parise <jon@php.net> * @author Jon Parise <jon@php.net>
* @author Chuck Hagenbuch <chuck@horde.org> * @author Chuck Hagenbuch <chuck@horde.org>
* @copyright 2010 Chuck Hagenbuch * @copyright 2010-2017 Chuck Hagenbuch
* @license http://opensource.org/licenses/bsd-license.php New BSD License * @license http://opensource.org/licenses/BSD-3-Clause New BSD License
* @version CVS: $Id$ * @version CVS: $Id$
* @link http://pear.php.net/package/Mail/ * @link http://pear.php.net/package/Mail/
*/ */
/** /**
* Z-Push changes * Z-Push changes
* *
* removed PEAR dependency by implementing own raiseError() * removed PEAR dependency by implementing own raiseError()
* *
* Reference implementation used: * Reference implementation used:
* http://download.pear.php.net/package/Mail-1.2.0.tgz * http://download.pear.php.net/package/Mail-1.4.1.tgz
* *
* *
*/ */
...@@ -59,7 +61,7 @@ ...@@ -59,7 +61,7 @@
* Sendmail implementation of the PEAR Mail:: interface. * Sendmail implementation of the PEAR Mail:: interface.
* @access public * @access public
* @package Mail * @package Mail
* @version $Revision: 294744 $ * @version $Revision$
*/ */
class Mail_sendmail extends Mail { class Mail_sendmail extends Mail {
...@@ -93,9 +95,8 @@ class Mail_sendmail extends Mail { ...@@ -93,9 +95,8 @@ class Mail_sendmail extends Mail {
* *
* @param array $params Hash containing any parameters different from the * @param array $params Hash containing any parameters different from the
* defaults. * defaults.
* @access public
*/ */
function __construct($params) public function __construct($params)
{ {
if (isset($params['sendmail_path'])) { if (isset($params['sendmail_path'])) {
$this->sendmail_path = $params['sendmail_path']; $this->sendmail_path = $params['sendmail_path'];
...@@ -139,9 +140,8 @@ class Mail_sendmail extends Mail { ...@@ -139,9 +140,8 @@ class Mail_sendmail extends Mail {
* @return mixed Returns true on success, or a PEAR_Error * @return mixed Returns true on success, or a PEAR_Error
* containing a descriptive error message on * containing a descriptive error message on
* failure. * failure.
* @access public
*/ */
function send($recipients, $headers, $body) public function send($recipients, $headers, $body)
{ {
if (!is_array($headers)) { if (!is_array($headers)) {
return Mail_sendmail::raiseError('$headers must be an array'); return Mail_sendmail::raiseError('$headers must be an array');
......
...@@ -2,31 +2,33 @@ ...@@ -2,31 +2,33 @@
/** /**
* SMTP implementation of the PEAR Mail interface. Requires the Net_SMTP class. * SMTP implementation of the PEAR Mail interface. Requires the Net_SMTP class.
* *
* PHP versions 4 and 5 * PHP version 5
* *
* LICENSE: * LICENSE:
* *
* Copyright (c) 2010, Chuck Hagenbuch * Copyright (c) 2010-2017, Chuck Hagenbuch & Jon Parise
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
* *
* o Redistributions of source code must retain the above copyright * 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* o Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the following disclaimer in the * 2. Redistributions in binary form must reproduce the above copyright
* documentation and/or other materials provided with the distribution. * notice, this list of conditions and the following disclaimer in the
* o The names of the authors may not be used to endorse or promote * documentation and/or other materials provided with the distribution.
* products derived from this software without specific prior written *
* permission. * 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
...@@ -36,21 +38,21 @@ ...@@ -36,21 +38,21 @@
* *
* @category HTTP * @category HTTP
* @package HTTP_Request * @package HTTP_Request
* @author Jon Parise <jon@php.net> * @author Jon Parise <jon@php.net>
* @author Chuck Hagenbuch <chuck@horde.org> * @author Chuck Hagenbuch <chuck@horde.org>
* @copyright 2010 Chuck Hagenbuch * @copyright 2010-2017 Chuck Hagenbuch
* @license http://opensource.org/licenses/bsd-license.php New BSD License * @license http://opensource.org/licenses/BSD-3-Clause New BSD License
* @version CVS: $Id: smtp.php 307488 2011-01-14 19:00:54Z alec $ * @version CVS: $Id$
* @link http://pear.php.net/package/Mail/ * @link http://pear.php.net/package/Mail/
*/ */
/** /**
* Z-Push changes * Z-Push changes
* *
* removed PEAR dependency by implementing own raiseError() * removed PEAR dependency by implementing own raiseError()
* *
* Reference implementation used: * Reference implementation used:
* http://download.pear.php.net/package/Mail-1.2.0.tgz * http://download.pear.php.net/package/Mail-1.4.1.tgz
* *
* *
*/ */
...@@ -80,7 +82,7 @@ define('PEAR_MAIL_SMTP_ERROR_DATA', 10006); ...@@ -80,7 +82,7 @@ define('PEAR_MAIL_SMTP_ERROR_DATA', 10006);
* SMTP implementation of the PEAR Mail interface. Requires the Net_SMTP class. * SMTP implementation of the PEAR Mail interface. Requires the Net_SMTP class.
* @access public * @access public
* @package Mail * @package Mail
* @version $Revision: 307488 $ * @version $Revision$
*/ */
class Mail_smtp extends Mail { class Mail_smtp extends Mail {
...@@ -95,18 +97,21 @@ class Mail_smtp extends Mail { ...@@ -95,18 +97,21 @@ class Mail_smtp extends Mail {
/** /**
* The list of service extension parameters to pass to the Net_SMTP * The list of service extension parameters to pass to the Net_SMTP
* mailFrom() command. * mailFrom() command.
*
* @var array * @var array
*/ */
var $_extparams = array(); var $_extparams = array();
/** /**
* The SMTP host to connect to. * The SMTP host to connect to.
*
* @var string * @var string
*/ */
var $host = 'localhost'; var $host = 'localhost';
/** /**
* The port the SMTP server is on. * The port the SMTP server is on.
*
* @var integer * @var integer
*/ */
var $port = 25; var $port = 25;
...@@ -126,12 +131,14 @@ class Mail_smtp extends Mail { ...@@ -126,12 +131,14 @@ class Mail_smtp extends Mail {
/** /**
* The username to use if the SMTP server requires authentication. * The username to use if the SMTP server requires authentication.
*
* @var string * @var string
*/ */
var $username = ''; var $username = '';
/** /**
* The password to use if the SMTP server requires authentication. * The password to use if the SMTP server requires authentication.
*
* @var string * @var string
*/ */
var $password = ''; var $password = '';
...@@ -170,27 +177,17 @@ class Mail_smtp extends Mail { ...@@ -170,27 +177,17 @@ class Mail_smtp extends Mail {
* Use SMTP command pipelining (specified in RFC 2920) if the SMTP server * Use SMTP command pipelining (specified in RFC 2920) if the SMTP server
* supports it. This speeds up delivery over high-latency connections. By * supports it. This speeds up delivery over high-latency connections. By
* default, use the default value supplied by Net_SMTP. * default, use the default value supplied by Net_SMTP.
* @var bool *
* @var boolean
*/ */
var $pipelining; var $pipelining;
/** /**
* Require verification of SSL certificate used. * The list of socket options
* @var bool *
*/ * @var array
var $verify_peer = true;
/**
* Require verification of peer name
* @var bool
*/
var $verify_peer_name = true;
/**
* Allow self-signed certificates. Requires verify_peer
* @var bool
*/ */
var $allow_self_signed = false; var $socket_options = array();
/** /**
* Constructor. * Constructor.
...@@ -215,9 +212,8 @@ class Mail_smtp extends Mail { ...@@ -215,9 +212,8 @@ class Mail_smtp extends Mail {
* *
* @param array Hash containing any parameters different from the * @param array Hash containing any parameters different from the
* defaults. * defaults.
* @access public
*/ */
function __construct($params) public function __construct($params)
{ {
if (isset($params['host'])) $this->host = $params['host']; if (isset($params['host'])) $this->host = $params['host'];
if (isset($params['port'])) $this->port = $params['port']; if (isset($params['port'])) $this->port = $params['port'];
...@@ -229,23 +225,18 @@ class Mail_smtp extends Mail { ...@@ -229,23 +225,18 @@ class Mail_smtp extends Mail {
if (isset($params['debug'])) $this->debug = (bool)$params['debug']; if (isset($params['debug'])) $this->debug = (bool)$params['debug'];
if (isset($params['persist'])) $this->persist = (bool)$params['persist']; if (isset($params['persist'])) $this->persist = (bool)$params['persist'];
if (isset($params['pipelining'])) $this->pipelining = (bool)$params['pipelining']; if (isset($params['pipelining'])) $this->pipelining = (bool)$params['pipelining'];
if (isset($params['verify_peer'])) $this->verify_peer = (bool)$params['verify_peer']; if (isset($params['socket_options'])) $this->socket_options = $params['socket_options'];
if (isset($params['verify_peer_name'])) $this->verify_peer_name = (bool)$params['verify_peer_name'];
if (isset($params['allow_self_signed'])) $this->allow_self_signed = (bool)$params['allow_self_signed'];
// Deprecated options // Deprecated options
if (isset($params['verp'])) { if (isset($params['verp'])) {
$this->addServiceExtensionParameter('XVERP', is_bool($params['verp']) ? null : $params['verp']); $this->addServiceExtensionParameter('XVERP', is_bool($params['verp']) ? null : $params['verp']);
} }
register_shutdown_function(array($this, '_Mail_smtp'));
} }
/** /**
* Destructor implementation to ensure that we disconnect from any * Destructor implementation to ensure that we disconnect from any
* potentially-alive persistent SMTP connections. * potentially-alive persistent SMTP connections.
*/ */
function _Mail_smtp() public function __destruct()
{ {
$this->disconnect(); $this->disconnect();
} }
...@@ -272,14 +263,25 @@ class Mail_smtp extends Mail { ...@@ -272,14 +263,25 @@ class Mail_smtp extends Mail {
* @return mixed Returns true on success, or a PEAR_Error * @return mixed Returns true on success, or a PEAR_Error
* containing a descriptive error message on * containing a descriptive error message on
* failure. * failure.
* @access public
*/ */
function send($recipients, $headers, $body) public function send($recipients, $headers, $body)
{
$result = $this->send_or_fail($recipients, $headers, $body);
/* If persistent connections are disabled, destroy our SMTP object. */
if ($this->persist === false) {
$this->disconnect();
}
return $result;
}
protected function send_or_fail($recipients, $headers, $body)
{ {
/* If we don't already have an SMTP object, create one. */ /* If we don't already have an SMTP object, create one. */
$result = &$this->getSMTPObject(); $result = $this->getSMTPObject();
//if (PEAR::isError($result)) { //if (PEAR::isError($result)) {
if ($result === false) { if ($this->_smtp === false) {
return $result; return $result;
} }
...@@ -342,15 +344,15 @@ class Mail_smtp extends Mail { ...@@ -342,15 +344,15 @@ class Mail_smtp extends Mail {
/* Send the message's headers and the body as SMTP data. */ /* Send the message's headers and the body as SMTP data. */
$res = $this->_smtp->data($body, $textHeaders); $res = $this->_smtp->data($body, $textHeaders);
list(,$args) = $this->_smtp->getResponse(); list(,$args) = $this->_smtp->getResponse();
if (preg_match("/Ok: queued as (.*)/", $args, $queued)) { if (preg_match("/ queued as (.*)/", $args, $queued)) {
$this->queued_as = $queued[1]; $this->queued_as = $queued[1];
} }
/* we need the greeting; from it we can extract the authorative name of the mail server we've really connected to. /* we need the greeting; from it we can extract the authorative name of the mail server we've really connected to.
* ideal if we're connecting to a round-robin of relay servers and need to track which exact one took the email */ * ideal if we're connecting to a round-robin of relay servers and need to track which exact one took the email */
$this->greeting = $this->_smtp->getGreeting(); $this->greeting = $this->_smtp->getGreeting();
//if (is_a($res, 'PEAR_Error')) { //if (is_a($res, 'PEAR_Error')) {
if ($res === false) { if ($res === false) {
...@@ -359,11 +361,6 @@ class Mail_smtp extends Mail { ...@@ -359,11 +361,6 @@ class Mail_smtp extends Mail {
return Mail_smtp::raiseError($error, PEAR_MAIL_SMTP_ERROR_DATA); return Mail_smtp::raiseError($error, PEAR_MAIL_SMTP_ERROR_DATA);
} }
/* If persistent connections are disabled, destroy our SMTP object. */
if ($this->persist === false) {
$this->disconnect();
}
return true; return true;
} }
...@@ -375,23 +372,20 @@ class Mail_smtp extends Mail { ...@@ -375,23 +372,20 @@ class Mail_smtp extends Mail {
* failure. * failure.
* *
* @since 1.2.0 * @since 1.2.0
* @access public
*/ */
function getSMTPObject() public function getSMTPObject()
{ {
if (is_object($this->_smtp) !== false) { if (is_object($this->_smtp) !== false) {
return $this->_smtp; return $this->_smtp;
} }
include_once 'Net/SMTP.php';
$this->_smtp = new Net_SMTP($this->host, $this->_smtp = new Net_SMTP($this->host,
$this->port, $this->port,
$this->localhost, $this->localhost,
$this->pipelining, $this->pipelining,
0, //timeout 0,
null, //socket_options $this->socket_options);
$this->verify_peer,
$this->verify_peer_name,
$this->allow_self_signed);
/* If we still don't have an SMTP object at this point, fail. */ /* If we still don't have an SMTP object at this point, fail. */
if (is_object($this->_smtp) === false) { if (is_object($this->_smtp) === false) {
...@@ -417,7 +411,9 @@ class Mail_smtp extends Mail { ...@@ -417,7 +411,9 @@ class Mail_smtp extends Mail {
if ($this->auth) { if ($this->auth) {
$method = is_string($this->auth) ? $this->auth : ''; $method = is_string($this->auth) ? $this->auth : '';
//if (PEAR::isError($res = $this->_smtp->auth($this->username, $this->password, $method))) { //if (PEAR::isError($res = $this->_smtp->auth($this->username,
// $this->password,
// $method))) {
if (($res = $this->_smtp->auth($this->username, $this->password, $method)) === false) { if (($res = $this->_smtp->auth($this->username, $this->password, $method)) === false) {
$error = $this->_error("$method authentication failure", $error = $this->_error("$method authentication failure",
$res); $res);
...@@ -436,9 +432,8 @@ class Mail_smtp extends Mail { ...@@ -436,9 +432,8 @@ class Mail_smtp extends Mail {
* @param string Any value the keyword needs. * @param string Any value the keyword needs.
* *
* @since 1.2.0 * @since 1.2.0
* @access public
*/ */
function addServiceExtensionParameter($keyword, $value = null) public function addServiceExtensionParameter($keyword, $value = null)
{ {
$this->_extparams[$keyword] = $value; $this->_extparams[$keyword] = $value;
} }
...@@ -449,9 +444,8 @@ class Mail_smtp extends Mail { ...@@ -449,9 +444,8 @@ class Mail_smtp extends Mail {
* @return boolean True if the SMTP connection no longer exists. * @return boolean True if the SMTP connection no longer exists.
* *
* @since 1.1.9 * @since 1.1.9
* @access public
*/ */
function disconnect() public function disconnect()
{ {
/* If we have an SMTP object, disconnect and destroy it. */ /* If we have an SMTP object, disconnect and destroy it. */
if (is_object($this->_smtp) && $this->_smtp->disconnect()) { if (is_object($this->_smtp) && $this->_smtp->disconnect()) {
...@@ -471,16 +465,15 @@ class Mail_smtp extends Mail { ...@@ -471,16 +465,15 @@ class Mail_smtp extends Mail {
* @return string A string describing the current SMTP error. * @return string A string describing the current SMTP error.
* *
* @since 1.1.7 * @since 1.1.7
* @access private
*/ */
function _error($text, &$error) protected function _error($text, $error)
{ {
/* Split the SMTP response into a code and a response string. */ /* Split the SMTP response into a code and a response string. */
list($code, $response) = $this->_smtp->getResponse(); list($code, $response) = $this->_smtp->getResponse();
/* Build our standardized error string. */ /* Build our standardized error string. */
return $text return $text
// . ' [SMTP: ' . $error->getMessage() //. ' [SMTP: ' . $error->getMessage()
. ' [SMTP: ' . ' [SMTP: '
. " (code: $code, response: $response)]"; . " (code: $code, response: $response)]";
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment