2008-08-22 22:17:14 +09:00
|
|
|
<?php
|
2016-02-26 21:34:07 +09:00
|
|
|
/** vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */
|
2008-08-22 22:17:14 +09:00
|
|
|
// +----------------------------------------------------------------------+
|
2016-02-26 21:34:07 +09:00
|
|
|
// | PHP Version 5 and 7 |
|
2008-08-22 22:17:14 +09:00
|
|
|
// +----------------------------------------------------------------------+
|
2016-02-26 21:34:07 +09:00
|
|
|
// | Copyright (c) 1997-2015 Jon Parise and Chuck Hagenbuch |
|
2008-08-22 22:17:14 +09:00
|
|
|
// +----------------------------------------------------------------------+
|
2016-02-26 21:34:07 +09:00
|
|
|
// | This source file is subject to version 3.01 of the PHP license, |
|
2008-08-22 22:17:14 +09:00
|
|
|
// | that is bundled with this package in the file LICENSE, and is |
|
|
|
|
// | available at through the world-wide-web at |
|
2016-02-26 21:34:07 +09:00
|
|
|
// | http://www.php.net/license/3_01.txt. |
|
2008-08-22 22:17:14 +09:00
|
|
|
// | 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 |
|
|
|
|
// | license@php.net so we can mail you a copy immediately. |
|
|
|
|
// +----------------------------------------------------------------------+
|
|
|
|
// | Authors: Chuck Hagenbuch <chuck@horde.org> |
|
|
|
|
// | Jon Parise <jon@php.net> |
|
|
|
|
// | Damian Alejandro Fernandez Sosa <damlists@cnba.uba.ar> |
|
|
|
|
// +----------------------------------------------------------------------+
|
|
|
|
|
|
|
|
require_once 'PEAR.php';
|
|
|
|
require_once 'Net/Socket.php';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Provides an implementation of the SMTP protocol using PEAR's
|
2016-02-26 21:34:07 +09:00
|
|
|
* Net_Socket class.
|
2008-08-22 22:17:14 +09:00
|
|
|
*
|
|
|
|
* @package Net_SMTP
|
|
|
|
* @author Chuck Hagenbuch <chuck@horde.org>
|
|
|
|
* @author Jon Parise <jon@php.net>
|
|
|
|
* @author Damian Alejandro Fernandez Sosa <damlists@cnba.uba.ar>
|
|
|
|
*
|
2016-02-26 21:34:07 +09:00
|
|
|
* @example basic.php A basic implementation of the Net_SMTP package.
|
2008-08-22 22:17:14 +09:00
|
|
|
*/
|
|
|
|
class Net_SMTP
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* The server to connect to.
|
|
|
|
* @var string
|
|
|
|
*/
|
2016-02-26 21:34:07 +09:00
|
|
|
public $host = 'localhost';
|
2008-08-22 22:17:14 +09:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The port to connect to.
|
|
|
|
* @var int
|
|
|
|
*/
|
2016-02-26 21:34:07 +09:00
|
|
|
public $port = 25;
|
2008-08-22 22:17:14 +09:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The value to give when sending EHLO or HELO.
|
|
|
|
* @var string
|
|
|
|
*/
|
2016-02-26 21:34:07 +09:00
|
|
|
public $localhost = 'localhost';
|
2008-08-22 22:17:14 +09:00
|
|
|
|
|
|
|
/**
|
|
|
|
* List of supported authentication methods, in preferential order.
|
|
|
|
* @var array
|
|
|
|
*/
|
2016-02-26 21:34:07 +09:00
|
|
|
public $auth_methods = array();
|
2008-08-22 22:17:14 +09:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Use SMTP command pipelining (specified in RFC 2920) if the SMTP
|
|
|
|
* server supports it.
|
|
|
|
*
|
|
|
|
* When pipeling is enabled, rcptTo(), mailFrom(), sendFrom(),
|
|
|
|
* somlFrom() and samlFrom() do not wait for a response from the
|
|
|
|
* SMTP server but return immediately.
|
|
|
|
*
|
|
|
|
* @var bool
|
|
|
|
*/
|
2016-02-26 21:34:07 +09:00
|
|
|
public $pipelining = false;
|
2008-08-22 22:17:14 +09:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Number of pipelined commands.
|
|
|
|
* @var int
|
|
|
|
*/
|
2016-02-26 21:34:07 +09:00
|
|
|
protected $pipelined_commands = 0;
|
2008-08-22 22:17:14 +09:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Should debugging output be enabled?
|
|
|
|
* @var boolean
|
|
|
|
*/
|
2016-02-26 21:34:07 +09:00
|
|
|
protected $debug = false;
|
2008-08-22 22:17:14 +09:00
|
|
|
|
extlibs updates: PEAR::Mail to 1.2.0, PEAR::Net_SMTP to 1.4.2 (need to go together as a pair)
PEAR::Mail updated to 1.2.0 from 1.1.4, fixes deprecation warnings on PHP 5.3, as well as:
1.2.0:
• QA release - stable.
• Updated minimum dependencies (Net_SMTP, PEAR, PHP)
• Doc Bug #15620 Licence change to BSD
• Bug #13659 Mail parse error in special condition
• Bug #16200 - Security hole allow to read/write Arbitrary File
_hasUnclosedQuotes() doesn't properly handle a double slash before an end quote (slusarz@curecanti.org, Bug #9137).
• Make sure Net_SMTP is defined when calling getSMTPObject() directly (slusarz@curecanti.org, Bug #13772).
• Add addServiceExtensionParameter() to the SMTP driver (slusarz@curecanti.org, Bug #13764).
• Add a method to obtain the Net_SMTP object from the SMTP driver (slusarz@curecanti.org, Bug #13766).
PEAR::Net_SMTP updated to 1.4.2 from 1.3.1, needed to support updated PEAR::Mail:
1.4.2:
• Fixing header string quoting in data(). (Bug #17199)
1.4.1:
• The auth() method now includes an optional $tls parameter that determines whether or not TLS should be attempted (if supported by the PHP runtime and the remote SMTP server). This parameter defaults to true. (Bug #16349)
• Header data can be specified separately from message body data by passing it as the optional second parameter to ``data()``. This is especially useful when an open file resource is being used to supply message data because it allows header fields (like *Subject:*) to be built dynamically at runtime. (Request #17012)
1.4.0:
• The data() method now accepts either a string or a file resource containing the message data. (Request #16962)
1.3.4:
• All Net_Socket write failures are now recognized. (Bug #16831)
1.3.3:
• Added getGreeting(), for retrieving the server's greeting string. (Request #16066) [needed for PEAR::Mail]
• We no longer attempt a TLS connection if we're already using a secure socket. (Bug #16254)
• You can now specify a debug output handler via setDebug(). (Request #16420)
1.3.2:
• TLS connection only gets started if no AUTH methods are sent. (Bug #14944)
2010-05-04 08:49:59 +09:00
|
|
|
/**
|
|
|
|
* Debug output handler.
|
|
|
|
* @var callback
|
|
|
|
*/
|
2016-02-26 21:34:07 +09:00
|
|
|
protected $debug_handler = null;
|
extlibs updates: PEAR::Mail to 1.2.0, PEAR::Net_SMTP to 1.4.2 (need to go together as a pair)
PEAR::Mail updated to 1.2.0 from 1.1.4, fixes deprecation warnings on PHP 5.3, as well as:
1.2.0:
• QA release - stable.
• Updated minimum dependencies (Net_SMTP, PEAR, PHP)
• Doc Bug #15620 Licence change to BSD
• Bug #13659 Mail parse error in special condition
• Bug #16200 - Security hole allow to read/write Arbitrary File
_hasUnclosedQuotes() doesn't properly handle a double slash before an end quote (slusarz@curecanti.org, Bug #9137).
• Make sure Net_SMTP is defined when calling getSMTPObject() directly (slusarz@curecanti.org, Bug #13772).
• Add addServiceExtensionParameter() to the SMTP driver (slusarz@curecanti.org, Bug #13764).
• Add a method to obtain the Net_SMTP object from the SMTP driver (slusarz@curecanti.org, Bug #13766).
PEAR::Net_SMTP updated to 1.4.2 from 1.3.1, needed to support updated PEAR::Mail:
1.4.2:
• Fixing header string quoting in data(). (Bug #17199)
1.4.1:
• The auth() method now includes an optional $tls parameter that determines whether or not TLS should be attempted (if supported by the PHP runtime and the remote SMTP server). This parameter defaults to true. (Bug #16349)
• Header data can be specified separately from message body data by passing it as the optional second parameter to ``data()``. This is especially useful when an open file resource is being used to supply message data because it allows header fields (like *Subject:*) to be built dynamically at runtime. (Request #17012)
1.4.0:
• The data() method now accepts either a string or a file resource containing the message data. (Request #16962)
1.3.4:
• All Net_Socket write failures are now recognized. (Bug #16831)
1.3.3:
• Added getGreeting(), for retrieving the server's greeting string. (Request #16066) [needed for PEAR::Mail]
• We no longer attempt a TLS connection if we're already using a secure socket. (Bug #16254)
• You can now specify a debug output handler via setDebug(). (Request #16420)
1.3.2:
• TLS connection only gets started if no AUTH methods are sent. (Bug #14944)
2010-05-04 08:49:59 +09:00
|
|
|
|
2008-08-22 22:17:14 +09:00
|
|
|
/**
|
|
|
|
* The socket resource being used to connect to the SMTP server.
|
|
|
|
* @var resource
|
|
|
|
*/
|
2016-02-26 21:34:07 +09:00
|
|
|
protected $socket = null;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Array of socket options that will be passed to Net_Socket::connect().
|
|
|
|
* @see stream_context_create()
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $socket_options = null;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The socket I/O timeout value in seconds.
|
|
|
|
* @var int
|
|
|
|
*/
|
|
|
|
protected $timeout = 0;
|
2008-08-22 22:17:14 +09:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The most recent server response code.
|
|
|
|
* @var int
|
|
|
|
*/
|
2016-02-26 21:34:07 +09:00
|
|
|
protected $code = -1;
|
2008-08-22 22:17:14 +09:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The most recent server response arguments.
|
|
|
|
* @var array
|
|
|
|
*/
|
2016-02-26 21:34:07 +09:00
|
|
|
protected $arguments = array();
|
2008-08-22 22:17:14 +09:00
|
|
|
|
extlibs updates: PEAR::Mail to 1.2.0, PEAR::Net_SMTP to 1.4.2 (need to go together as a pair)
PEAR::Mail updated to 1.2.0 from 1.1.4, fixes deprecation warnings on PHP 5.3, as well as:
1.2.0:
• QA release - stable.
• Updated minimum dependencies (Net_SMTP, PEAR, PHP)
• Doc Bug #15620 Licence change to BSD
• Bug #13659 Mail parse error in special condition
• Bug #16200 - Security hole allow to read/write Arbitrary File
_hasUnclosedQuotes() doesn't properly handle a double slash before an end quote (slusarz@curecanti.org, Bug #9137).
• Make sure Net_SMTP is defined when calling getSMTPObject() directly (slusarz@curecanti.org, Bug #13772).
• Add addServiceExtensionParameter() to the SMTP driver (slusarz@curecanti.org, Bug #13764).
• Add a method to obtain the Net_SMTP object from the SMTP driver (slusarz@curecanti.org, Bug #13766).
PEAR::Net_SMTP updated to 1.4.2 from 1.3.1, needed to support updated PEAR::Mail:
1.4.2:
• Fixing header string quoting in data(). (Bug #17199)
1.4.1:
• The auth() method now includes an optional $tls parameter that determines whether or not TLS should be attempted (if supported by the PHP runtime and the remote SMTP server). This parameter defaults to true. (Bug #16349)
• Header data can be specified separately from message body data by passing it as the optional second parameter to ``data()``. This is especially useful when an open file resource is being used to supply message data because it allows header fields (like *Subject:*) to be built dynamically at runtime. (Request #17012)
1.4.0:
• The data() method now accepts either a string or a file resource containing the message data. (Request #16962)
1.3.4:
• All Net_Socket write failures are now recognized. (Bug #16831)
1.3.3:
• Added getGreeting(), for retrieving the server's greeting string. (Request #16066) [needed for PEAR::Mail]
• We no longer attempt a TLS connection if we're already using a secure socket. (Bug #16254)
• You can now specify a debug output handler via setDebug(). (Request #16420)
1.3.2:
• TLS connection only gets started if no AUTH methods are sent. (Bug #14944)
2010-05-04 08:49:59 +09:00
|
|
|
/**
|
|
|
|
* Stores the SMTP server's greeting string.
|
|
|
|
* @var string
|
|
|
|
*/
|
2016-02-26 21:34:07 +09:00
|
|
|
protected $greeting = null;
|
extlibs updates: PEAR::Mail to 1.2.0, PEAR::Net_SMTP to 1.4.2 (need to go together as a pair)
PEAR::Mail updated to 1.2.0 from 1.1.4, fixes deprecation warnings on PHP 5.3, as well as:
1.2.0:
• QA release - stable.
• Updated minimum dependencies (Net_SMTP, PEAR, PHP)
• Doc Bug #15620 Licence change to BSD
• Bug #13659 Mail parse error in special condition
• Bug #16200 - Security hole allow to read/write Arbitrary File
_hasUnclosedQuotes() doesn't properly handle a double slash before an end quote (slusarz@curecanti.org, Bug #9137).
• Make sure Net_SMTP is defined when calling getSMTPObject() directly (slusarz@curecanti.org, Bug #13772).
• Add addServiceExtensionParameter() to the SMTP driver (slusarz@curecanti.org, Bug #13764).
• Add a method to obtain the Net_SMTP object from the SMTP driver (slusarz@curecanti.org, Bug #13766).
PEAR::Net_SMTP updated to 1.4.2 from 1.3.1, needed to support updated PEAR::Mail:
1.4.2:
• Fixing header string quoting in data(). (Bug #17199)
1.4.1:
• The auth() method now includes an optional $tls parameter that determines whether or not TLS should be attempted (if supported by the PHP runtime and the remote SMTP server). This parameter defaults to true. (Bug #16349)
• Header data can be specified separately from message body data by passing it as the optional second parameter to ``data()``. This is especially useful when an open file resource is being used to supply message data because it allows header fields (like *Subject:*) to be built dynamically at runtime. (Request #17012)
1.4.0:
• The data() method now accepts either a string or a file resource containing the message data. (Request #16962)
1.3.4:
• All Net_Socket write failures are now recognized. (Bug #16831)
1.3.3:
• Added getGreeting(), for retrieving the server's greeting string. (Request #16066) [needed for PEAR::Mail]
• We no longer attempt a TLS connection if we're already using a secure socket. (Bug #16254)
• You can now specify a debug output handler via setDebug(). (Request #16420)
1.3.2:
• TLS connection only gets started if no AUTH methods are sent. (Bug #14944)
2010-05-04 08:49:59 +09:00
|
|
|
|
2008-08-22 22:17:14 +09:00
|
|
|
/**
|
|
|
|
* Stores detected features of the SMTP server.
|
|
|
|
* @var array
|
|
|
|
*/
|
2016-02-26 21:34:07 +09:00
|
|
|
protected $esmtp = array();
|
2008-08-22 22:17:14 +09:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Instantiates a new Net_SMTP object, overriding any defaults
|
|
|
|
* with parameters that are passed in.
|
|
|
|
*
|
|
|
|
* If you have SSL support in PHP, you can connect to a server
|
|
|
|
* over SSL using an 'ssl://' prefix:
|
|
|
|
*
|
|
|
|
* // 465 is a common smtps port.
|
|
|
|
* $smtp = new Net_SMTP('ssl://mail.host.com', 465);
|
|
|
|
* $smtp->connect();
|
|
|
|
*
|
2016-02-26 21:34:07 +09:00
|
|
|
* @param string $host The server to connect to.
|
|
|
|
* @param integer $port The port to connect to.
|
|
|
|
* @param string $localhost The value to give when sending EHLO or HELO.
|
|
|
|
* @param boolean $pipelining Use SMTP command pipelining
|
|
|
|
* @param integer $timeout Socket I/O timeout in seconds.
|
|
|
|
* @param array $socket_options Socket stream_context_create() options.
|
2008-08-22 22:17:14 +09:00
|
|
|
*
|
2016-02-26 21:34:07 +09:00
|
|
|
* @since 1.0
|
2008-08-22 22:17:14 +09:00
|
|
|
*/
|
2016-02-26 21:34:07 +09:00
|
|
|
public function __construct($host = null, $port = null, $localhost = null,
|
|
|
|
$pipelining = false, $timeout = 0, $socket_options = null
|
|
|
|
) {
|
2008-08-22 22:17:14 +09:00
|
|
|
if (isset($host)) {
|
|
|
|
$this->host = $host;
|
|
|
|
}
|
|
|
|
if (isset($port)) {
|
|
|
|
$this->port = $port;
|
|
|
|
}
|
|
|
|
if (isset($localhost)) {
|
|
|
|
$this->localhost = $localhost;
|
|
|
|
}
|
|
|
|
|
2016-02-26 21:34:07 +09:00
|
|
|
$this->pipelining = $pipelining;
|
|
|
|
$this->socket = new Net_Socket();
|
|
|
|
$this->socket_options = $socket_options;
|
|
|
|
$this->timeout = $timeout;
|
2008-08-22 22:17:14 +09:00
|
|
|
|
2016-02-26 21:34:07 +09:00
|
|
|
/* Include the Auth_SASL package. If the package is available, we
|
|
|
|
* enable the authentication methods that depend upon it. */
|
|
|
|
if (@include_once 'Auth/SASL.php') {
|
|
|
|
$this->setAuthMethod('CRAM-MD5', array($this, 'authCramMD5'));
|
|
|
|
$this->setAuthMethod('DIGEST-MD5', array($this, 'authDigestMD5'));
|
2008-08-22 22:17:14 +09:00
|
|
|
}
|
2016-02-26 21:34:07 +09:00
|
|
|
|
|
|
|
/* These standard authentication methods are always available. */
|
|
|
|
$this->setAuthMethod('LOGIN', array($this, 'authLogin'), false);
|
|
|
|
$this->setAuthMethod('PLAIN', array($this, 'authPlain'), false);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the socket I/O timeout value in seconds plus microseconds.
|
|
|
|
*
|
|
|
|
* @param integer $seconds Timeout value in seconds.
|
|
|
|
* @param integer $microseconds Additional value in microseconds.
|
|
|
|
*
|
|
|
|
* @since 1.5.0
|
|
|
|
*/
|
|
|
|
public function setTimeout($seconds, $microseconds = 0)
|
|
|
|
{
|
|
|
|
return $this->socket->setTimeout($seconds, $microseconds);
|
2008-08-22 22:17:14 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the value of the debugging flag.
|
|
|
|
*
|
2016-02-26 21:34:07 +09:00
|
|
|
* @param boolean $debug New value for the debugging flag.
|
|
|
|
* @param callback $handler Debug handler callback
|
2008-08-22 22:17:14 +09:00
|
|
|
*
|
2016-02-26 21:34:07 +09:00
|
|
|
* @since 1.1.0
|
2008-08-22 22:17:14 +09:00
|
|
|
*/
|
2016-02-26 21:34:07 +09:00
|
|
|
public function setDebug($debug, $handler = null)
|
2008-08-22 22:17:14 +09:00
|
|
|
{
|
2016-02-26 21:34:07 +09:00
|
|
|
$this->debug = $debug;
|
|
|
|
$this->debug_handler = $handler;
|
extlibs updates: PEAR::Mail to 1.2.0, PEAR::Net_SMTP to 1.4.2 (need to go together as a pair)
PEAR::Mail updated to 1.2.0 from 1.1.4, fixes deprecation warnings on PHP 5.3, as well as:
1.2.0:
• QA release - stable.
• Updated minimum dependencies (Net_SMTP, PEAR, PHP)
• Doc Bug #15620 Licence change to BSD
• Bug #13659 Mail parse error in special condition
• Bug #16200 - Security hole allow to read/write Arbitrary File
_hasUnclosedQuotes() doesn't properly handle a double slash before an end quote (slusarz@curecanti.org, Bug #9137).
• Make sure Net_SMTP is defined when calling getSMTPObject() directly (slusarz@curecanti.org, Bug #13772).
• Add addServiceExtensionParameter() to the SMTP driver (slusarz@curecanti.org, Bug #13764).
• Add a method to obtain the Net_SMTP object from the SMTP driver (slusarz@curecanti.org, Bug #13766).
PEAR::Net_SMTP updated to 1.4.2 from 1.3.1, needed to support updated PEAR::Mail:
1.4.2:
• Fixing header string quoting in data(). (Bug #17199)
1.4.1:
• The auth() method now includes an optional $tls parameter that determines whether or not TLS should be attempted (if supported by the PHP runtime and the remote SMTP server). This parameter defaults to true. (Bug #16349)
• Header data can be specified separately from message body data by passing it as the optional second parameter to ``data()``. This is especially useful when an open file resource is being used to supply message data because it allows header fields (like *Subject:*) to be built dynamically at runtime. (Request #17012)
1.4.0:
• The data() method now accepts either a string or a file resource containing the message data. (Request #16962)
1.3.4:
• All Net_Socket write failures are now recognized. (Bug #16831)
1.3.3:
• Added getGreeting(), for retrieving the server's greeting string. (Request #16066) [needed for PEAR::Mail]
• We no longer attempt a TLS connection if we're already using a secure socket. (Bug #16254)
• You can now specify a debug output handler via setDebug(). (Request #16420)
1.3.2:
• TLS connection only gets started if no AUTH methods are sent. (Bug #14944)
2010-05-04 08:49:59 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Write the given debug text to the current debug output handler.
|
|
|
|
*
|
2016-02-26 21:34:07 +09:00
|
|
|
* @param string $message Debug mesage text.
|
extlibs updates: PEAR::Mail to 1.2.0, PEAR::Net_SMTP to 1.4.2 (need to go together as a pair)
PEAR::Mail updated to 1.2.0 from 1.1.4, fixes deprecation warnings on PHP 5.3, as well as:
1.2.0:
• QA release - stable.
• Updated minimum dependencies (Net_SMTP, PEAR, PHP)
• Doc Bug #15620 Licence change to BSD
• Bug #13659 Mail parse error in special condition
• Bug #16200 - Security hole allow to read/write Arbitrary File
_hasUnclosedQuotes() doesn't properly handle a double slash before an end quote (slusarz@curecanti.org, Bug #9137).
• Make sure Net_SMTP is defined when calling getSMTPObject() directly (slusarz@curecanti.org, Bug #13772).
• Add addServiceExtensionParameter() to the SMTP driver (slusarz@curecanti.org, Bug #13764).
• Add a method to obtain the Net_SMTP object from the SMTP driver (slusarz@curecanti.org, Bug #13766).
PEAR::Net_SMTP updated to 1.4.2 from 1.3.1, needed to support updated PEAR::Mail:
1.4.2:
• Fixing header string quoting in data(). (Bug #17199)
1.4.1:
• The auth() method now includes an optional $tls parameter that determines whether or not TLS should be attempted (if supported by the PHP runtime and the remote SMTP server). This parameter defaults to true. (Bug #16349)
• Header data can be specified separately from message body data by passing it as the optional second parameter to ``data()``. This is especially useful when an open file resource is being used to supply message data because it allows header fields (like *Subject:*) to be built dynamically at runtime. (Request #17012)
1.4.0:
• The data() method now accepts either a string or a file resource containing the message data. (Request #16962)
1.3.4:
• All Net_Socket write failures are now recognized. (Bug #16831)
1.3.3:
• Added getGreeting(), for retrieving the server's greeting string. (Request #16066) [needed for PEAR::Mail]
• We no longer attempt a TLS connection if we're already using a secure socket. (Bug #16254)
• You can now specify a debug output handler via setDebug(). (Request #16420)
1.3.2:
• TLS connection only gets started if no AUTH methods are sent. (Bug #14944)
2010-05-04 08:49:59 +09:00
|
|
|
*
|
2016-02-26 21:34:07 +09:00
|
|
|
* @since 1.3.3
|
extlibs updates: PEAR::Mail to 1.2.0, PEAR::Net_SMTP to 1.4.2 (need to go together as a pair)
PEAR::Mail updated to 1.2.0 from 1.1.4, fixes deprecation warnings on PHP 5.3, as well as:
1.2.0:
• QA release - stable.
• Updated minimum dependencies (Net_SMTP, PEAR, PHP)
• Doc Bug #15620 Licence change to BSD
• Bug #13659 Mail parse error in special condition
• Bug #16200 - Security hole allow to read/write Arbitrary File
_hasUnclosedQuotes() doesn't properly handle a double slash before an end quote (slusarz@curecanti.org, Bug #9137).
• Make sure Net_SMTP is defined when calling getSMTPObject() directly (slusarz@curecanti.org, Bug #13772).
• Add addServiceExtensionParameter() to the SMTP driver (slusarz@curecanti.org, Bug #13764).
• Add a method to obtain the Net_SMTP object from the SMTP driver (slusarz@curecanti.org, Bug #13766).
PEAR::Net_SMTP updated to 1.4.2 from 1.3.1, needed to support updated PEAR::Mail:
1.4.2:
• Fixing header string quoting in data(). (Bug #17199)
1.4.1:
• The auth() method now includes an optional $tls parameter that determines whether or not TLS should be attempted (if supported by the PHP runtime and the remote SMTP server). This parameter defaults to true. (Bug #16349)
• Header data can be specified separately from message body data by passing it as the optional second parameter to ``data()``. This is especially useful when an open file resource is being used to supply message data because it allows header fields (like *Subject:*) to be built dynamically at runtime. (Request #17012)
1.4.0:
• The data() method now accepts either a string or a file resource containing the message data. (Request #16962)
1.3.4:
• All Net_Socket write failures are now recognized. (Bug #16831)
1.3.3:
• Added getGreeting(), for retrieving the server's greeting string. (Request #16066) [needed for PEAR::Mail]
• We no longer attempt a TLS connection if we're already using a secure socket. (Bug #16254)
• You can now specify a debug output handler via setDebug(). (Request #16420)
1.3.2:
• TLS connection only gets started if no AUTH methods are sent. (Bug #14944)
2010-05-04 08:49:59 +09:00
|
|
|
*/
|
2016-02-26 21:34:07 +09:00
|
|
|
protected function debug($message)
|
extlibs updates: PEAR::Mail to 1.2.0, PEAR::Net_SMTP to 1.4.2 (need to go together as a pair)
PEAR::Mail updated to 1.2.0 from 1.1.4, fixes deprecation warnings on PHP 5.3, as well as:
1.2.0:
• QA release - stable.
• Updated minimum dependencies (Net_SMTP, PEAR, PHP)
• Doc Bug #15620 Licence change to BSD
• Bug #13659 Mail parse error in special condition
• Bug #16200 - Security hole allow to read/write Arbitrary File
_hasUnclosedQuotes() doesn't properly handle a double slash before an end quote (slusarz@curecanti.org, Bug #9137).
• Make sure Net_SMTP is defined when calling getSMTPObject() directly (slusarz@curecanti.org, Bug #13772).
• Add addServiceExtensionParameter() to the SMTP driver (slusarz@curecanti.org, Bug #13764).
• Add a method to obtain the Net_SMTP object from the SMTP driver (slusarz@curecanti.org, Bug #13766).
PEAR::Net_SMTP updated to 1.4.2 from 1.3.1, needed to support updated PEAR::Mail:
1.4.2:
• Fixing header string quoting in data(). (Bug #17199)
1.4.1:
• The auth() method now includes an optional $tls parameter that determines whether or not TLS should be attempted (if supported by the PHP runtime and the remote SMTP server). This parameter defaults to true. (Bug #16349)
• Header data can be specified separately from message body data by passing it as the optional second parameter to ``data()``. This is especially useful when an open file resource is being used to supply message data because it allows header fields (like *Subject:*) to be built dynamically at runtime. (Request #17012)
1.4.0:
• The data() method now accepts either a string or a file resource containing the message data. (Request #16962)
1.3.4:
• All Net_Socket write failures are now recognized. (Bug #16831)
1.3.3:
• Added getGreeting(), for retrieving the server's greeting string. (Request #16066) [needed for PEAR::Mail]
• We no longer attempt a TLS connection if we're already using a secure socket. (Bug #16254)
• You can now specify a debug output handler via setDebug(). (Request #16420)
1.3.2:
• TLS connection only gets started if no AUTH methods are sent. (Bug #14944)
2010-05-04 08:49:59 +09:00
|
|
|
{
|
2016-02-26 21:34:07 +09:00
|
|
|
if ($this->debug) {
|
|
|
|
if ($this->debug_handler) {
|
|
|
|
call_user_func_array(
|
|
|
|
$this->debug_handler, array(&$this, $message)
|
|
|
|
);
|
extlibs updates: PEAR::Mail to 1.2.0, PEAR::Net_SMTP to 1.4.2 (need to go together as a pair)
PEAR::Mail updated to 1.2.0 from 1.1.4, fixes deprecation warnings on PHP 5.3, as well as:
1.2.0:
• QA release - stable.
• Updated minimum dependencies (Net_SMTP, PEAR, PHP)
• Doc Bug #15620 Licence change to BSD
• Bug #13659 Mail parse error in special condition
• Bug #16200 - Security hole allow to read/write Arbitrary File
_hasUnclosedQuotes() doesn't properly handle a double slash before an end quote (slusarz@curecanti.org, Bug #9137).
• Make sure Net_SMTP is defined when calling getSMTPObject() directly (slusarz@curecanti.org, Bug #13772).
• Add addServiceExtensionParameter() to the SMTP driver (slusarz@curecanti.org, Bug #13764).
• Add a method to obtain the Net_SMTP object from the SMTP driver (slusarz@curecanti.org, Bug #13766).
PEAR::Net_SMTP updated to 1.4.2 from 1.3.1, needed to support updated PEAR::Mail:
1.4.2:
• Fixing header string quoting in data(). (Bug #17199)
1.4.1:
• The auth() method now includes an optional $tls parameter that determines whether or not TLS should be attempted (if supported by the PHP runtime and the remote SMTP server). This parameter defaults to true. (Bug #16349)
• Header data can be specified separately from message body data by passing it as the optional second parameter to ``data()``. This is especially useful when an open file resource is being used to supply message data because it allows header fields (like *Subject:*) to be built dynamically at runtime. (Request #17012)
1.4.0:
• The data() method now accepts either a string or a file resource containing the message data. (Request #16962)
1.3.4:
• All Net_Socket write failures are now recognized. (Bug #16831)
1.3.3:
• Added getGreeting(), for retrieving the server's greeting string. (Request #16066) [needed for PEAR::Mail]
• We no longer attempt a TLS connection if we're already using a secure socket. (Bug #16254)
• You can now specify a debug output handler via setDebug(). (Request #16420)
1.3.2:
• TLS connection only gets started if no AUTH methods are sent. (Bug #14944)
2010-05-04 08:49:59 +09:00
|
|
|
} else {
|
|
|
|
echo "DEBUG: $message\n";
|
|
|
|
}
|
|
|
|
}
|
2008-08-22 22:17:14 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Send the given string of data to the server.
|
|
|
|
*
|
2016-02-26 21:34:07 +09:00
|
|
|
* @param string $data The string of data to send.
|
2008-08-22 22:17:14 +09:00
|
|
|
*
|
2016-02-26 21:34:07 +09:00
|
|
|
* @return mixed The number of bytes that were actually written,
|
|
|
|
* or a PEAR_Error object on failure.
|
2008-08-22 22:17:14 +09:00
|
|
|
*
|
2016-02-26 21:34:07 +09:00
|
|
|
* @since 1.1.0
|
2008-08-22 22:17:14 +09:00
|
|
|
*/
|
2016-02-26 21:34:07 +09:00
|
|
|
protected function send($data)
|
2008-08-22 22:17:14 +09:00
|
|
|
{
|
2016-02-26 21:34:07 +09:00
|
|
|
$this->debug("Send: $data");
|
2008-08-22 22:17:14 +09:00
|
|
|
|
2016-02-26 21:34:07 +09:00
|
|
|
$result = $this->socket->write($data);
|
|
|
|
if (!$result || PEAR::isError($result)) {
|
|
|
|
$msg = $result ? $result->getMessage() : "unknown error";
|
extlibs updates: PEAR::Mail to 1.2.0, PEAR::Net_SMTP to 1.4.2 (need to go together as a pair)
PEAR::Mail updated to 1.2.0 from 1.1.4, fixes deprecation warnings on PHP 5.3, as well as:
1.2.0:
• QA release - stable.
• Updated minimum dependencies (Net_SMTP, PEAR, PHP)
• Doc Bug #15620 Licence change to BSD
• Bug #13659 Mail parse error in special condition
• Bug #16200 - Security hole allow to read/write Arbitrary File
_hasUnclosedQuotes() doesn't properly handle a double slash before an end quote (slusarz@curecanti.org, Bug #9137).
• Make sure Net_SMTP is defined when calling getSMTPObject() directly (slusarz@curecanti.org, Bug #13772).
• Add addServiceExtensionParameter() to the SMTP driver (slusarz@curecanti.org, Bug #13764).
• Add a method to obtain the Net_SMTP object from the SMTP driver (slusarz@curecanti.org, Bug #13766).
PEAR::Net_SMTP updated to 1.4.2 from 1.3.1, needed to support updated PEAR::Mail:
1.4.2:
• Fixing header string quoting in data(). (Bug #17199)
1.4.1:
• The auth() method now includes an optional $tls parameter that determines whether or not TLS should be attempted (if supported by the PHP runtime and the remote SMTP server). This parameter defaults to true. (Bug #16349)
• Header data can be specified separately from message body data by passing it as the optional second parameter to ``data()``. This is especially useful when an open file resource is being used to supply message data because it allows header fields (like *Subject:*) to be built dynamically at runtime. (Request #17012)
1.4.0:
• The data() method now accepts either a string or a file resource containing the message data. (Request #16962)
1.3.4:
• All Net_Socket write failures are now recognized. (Bug #16831)
1.3.3:
• Added getGreeting(), for retrieving the server's greeting string. (Request #16066) [needed for PEAR::Mail]
• We no longer attempt a TLS connection if we're already using a secure socket. (Bug #16254)
• You can now specify a debug output handler via setDebug(). (Request #16420)
1.3.2:
• TLS connection only gets started if no AUTH methods are sent. (Bug #14944)
2010-05-04 08:49:59 +09:00
|
|
|
return PEAR::raiseError("Failed to write to socket: $msg");
|
2008-08-22 22:17:14 +09:00
|
|
|
}
|
|
|
|
|
2016-02-26 21:34:07 +09:00
|
|
|
return $result;
|
2008-08-22 22:17:14 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Send a command to the server with an optional string of
|
|
|
|
* arguments. A carriage return / linefeed (CRLF) sequence will
|
|
|
|
* be appended to each command string before it is sent to the
|
|
|
|
* SMTP server - an error will be thrown if the command string
|
2016-02-26 21:34:07 +09:00
|
|
|
* already contains any newline characters. Use send() for
|
2008-08-22 22:17:14 +09:00
|
|
|
* commands that must contain newlines.
|
|
|
|
*
|
2016-02-26 21:34:07 +09:00
|
|
|
* @param string $command The SMTP command to send to the server.
|
|
|
|
* @param string $args A string of optional arguments to append
|
|
|
|
* to the command.
|
2008-08-22 22:17:14 +09:00
|
|
|
*
|
2016-02-26 21:34:07 +09:00
|
|
|
* @return mixed The result of the send() call.
|
2008-08-22 22:17:14 +09:00
|
|
|
*
|
2016-02-26 21:34:07 +09:00
|
|
|
* @since 1.1.0
|
2008-08-22 22:17:14 +09:00
|
|
|
*/
|
2016-02-26 21:34:07 +09:00
|
|
|
protected function put($command, $args = '')
|
2008-08-22 22:17:14 +09:00
|
|
|
{
|
|
|
|
if (!empty($args)) {
|
|
|
|
$command .= ' ' . $args;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strcspn($command, "\r\n") !== strlen($command)) {
|
|
|
|
return PEAR::raiseError('Commands cannot contain newlines');
|
|
|
|
}
|
|
|
|
|
2016-02-26 21:34:07 +09:00
|
|
|
return $this->send($command . "\r\n");
|
2008-08-22 22:17:14 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Read a reply from the SMTP server. The reply consists of a response
|
|
|
|
* code and a response message.
|
|
|
|
*
|
2016-02-26 21:34:07 +09:00
|
|
|
* @param mixed $valid The set of valid response codes. These
|
|
|
|
* may be specified as an array of integer
|
|
|
|
* values or as a single integer value.
|
|
|
|
* @param bool $later Do not parse the response now, but wait
|
|
|
|
* until the last command in the pipelined
|
|
|
|
* command group
|
2008-08-22 22:17:14 +09:00
|
|
|
*
|
2016-02-26 21:34:07 +09:00
|
|
|
* @return mixed True if the server returned a valid response code or
|
|
|
|
* a PEAR_Error object is an error condition is reached.
|
2008-08-22 22:17:14 +09:00
|
|
|
*
|
2016-02-26 21:34:07 +09:00
|
|
|
* @since 1.1.0
|
2008-08-22 22:17:14 +09:00
|
|
|
*
|
2016-02-26 21:34:07 +09:00
|
|
|
* @see getResponse
|
2008-08-22 22:17:14 +09:00
|
|
|
*/
|
2016-02-26 21:34:07 +09:00
|
|
|
protected function parseResponse($valid, $later = false)
|
2008-08-22 22:17:14 +09:00
|
|
|
{
|
2016-02-26 21:34:07 +09:00
|
|
|
$this->code = -1;
|
|
|
|
$this->arguments = array();
|
2008-08-22 22:17:14 +09:00
|
|
|
|
|
|
|
if ($later) {
|
2016-02-26 21:34:07 +09:00
|
|
|
$this->pipelined_commands++;
|
2008-08-22 22:17:14 +09:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-02-26 21:34:07 +09:00
|
|
|
for ($i = 0; $i <= $this->pipelined_commands; $i++) {
|
|
|
|
while ($line = $this->socket->readLine()) {
|
|
|
|
$this->debug("Recv: $line");
|
2008-08-22 22:17:14 +09:00
|
|
|
|
2016-02-26 21:34:07 +09:00
|
|
|
/* If we receive an empty line, the connection was closed. */
|
2008-08-22 22:17:14 +09:00
|
|
|
if (empty($line)) {
|
|
|
|
$this->disconnect();
|
2016-02-26 21:34:07 +09:00
|
|
|
return PEAR::raiseError('Connection was closed');
|
2008-08-22 22:17:14 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Read the code and store the rest in the arguments array. */
|
|
|
|
$code = substr($line, 0, 3);
|
2016-02-26 21:34:07 +09:00
|
|
|
$this->arguments[] = trim(substr($line, 4));
|
2008-08-22 22:17:14 +09:00
|
|
|
|
|
|
|
/* Check the syntax of the response code. */
|
|
|
|
if (is_numeric($code)) {
|
2016-02-26 21:34:07 +09:00
|
|
|
$this->code = (int)$code;
|
2008-08-22 22:17:14 +09:00
|
|
|
} else {
|
2016-02-26 21:34:07 +09:00
|
|
|
$this->code = -1;
|
2008-08-22 22:17:14 +09:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If this is not a multiline response, we're done. */
|
|
|
|
if (substr($line, 3, 1) != '-') {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-26 21:34:07 +09:00
|
|
|
$this->pipelined_commands = 0;
|
2008-08-22 22:17:14 +09:00
|
|
|
|
|
|
|
/* Compare the server's response code with the valid code/codes. */
|
2016-02-26 21:34:07 +09:00
|
|
|
if (is_int($valid) && ($this->code === $valid)) {
|
2008-08-22 22:17:14 +09:00
|
|
|
return true;
|
2016-02-26 21:34:07 +09:00
|
|
|
} elseif (is_array($valid) && in_array($this->code, $valid, true)) {
|
2008-08-22 22:17:14 +09:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-02-26 21:34:07 +09:00
|
|
|
return PEAR::raiseError('Invalid response code received from server', $this->code);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Issue an SMTP command and verify its response.
|
|
|
|
*
|
|
|
|
* @param string $command The SMTP command string or data.
|
|
|
|
* @param mixed $valid The set of valid response codes. These
|
|
|
|
* may be specified as an array of integer
|
|
|
|
* values or as a single integer value.
|
|
|
|
*
|
|
|
|
* @return mixed True on success or a PEAR_Error object on failure.
|
|
|
|
*
|
|
|
|
* @since 1.6.0
|
|
|
|
*/
|
|
|
|
public function command($command, $valid)
|
|
|
|
{
|
|
|
|
if (PEAR::isError($error = $this->put($command))) {
|
|
|
|
return $error;
|
|
|
|
}
|
|
|
|
if (PEAR::isError($error = $this->parseResponse($valid))) {
|
|
|
|
return $error;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
2008-08-22 22:17:14 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return a 2-tuple containing the last response from the SMTP server.
|
|
|
|
*
|
2016-02-26 21:34:07 +09:00
|
|
|
* @return array A two-element array: the first element contains the
|
|
|
|
* response code as an integer and the second element
|
|
|
|
* contains the response's arguments as a string.
|
2008-08-22 22:17:14 +09:00
|
|
|
*
|
2016-02-26 21:34:07 +09:00
|
|
|
* @since 1.1.0
|
2008-08-22 22:17:14 +09:00
|
|
|
*/
|
2016-02-26 21:34:07 +09:00
|
|
|
public function getResponse()
|
2008-08-22 22:17:14 +09:00
|
|
|
{
|
2016-02-26 21:34:07 +09:00
|
|
|
return array($this->code, join("\n", $this->arguments));
|
2008-08-22 22:17:14 +09:00
|
|
|
}
|
|
|
|
|
extlibs updates: PEAR::Mail to 1.2.0, PEAR::Net_SMTP to 1.4.2 (need to go together as a pair)
PEAR::Mail updated to 1.2.0 from 1.1.4, fixes deprecation warnings on PHP 5.3, as well as:
1.2.0:
• QA release - stable.
• Updated minimum dependencies (Net_SMTP, PEAR, PHP)
• Doc Bug #15620 Licence change to BSD
• Bug #13659 Mail parse error in special condition
• Bug #16200 - Security hole allow to read/write Arbitrary File
_hasUnclosedQuotes() doesn't properly handle a double slash before an end quote (slusarz@curecanti.org, Bug #9137).
• Make sure Net_SMTP is defined when calling getSMTPObject() directly (slusarz@curecanti.org, Bug #13772).
• Add addServiceExtensionParameter() to the SMTP driver (slusarz@curecanti.org, Bug #13764).
• Add a method to obtain the Net_SMTP object from the SMTP driver (slusarz@curecanti.org, Bug #13766).
PEAR::Net_SMTP updated to 1.4.2 from 1.3.1, needed to support updated PEAR::Mail:
1.4.2:
• Fixing header string quoting in data(). (Bug #17199)
1.4.1:
• The auth() method now includes an optional $tls parameter that determines whether or not TLS should be attempted (if supported by the PHP runtime and the remote SMTP server). This parameter defaults to true. (Bug #16349)
• Header data can be specified separately from message body data by passing it as the optional second parameter to ``data()``. This is especially useful when an open file resource is being used to supply message data because it allows header fields (like *Subject:*) to be built dynamically at runtime. (Request #17012)
1.4.0:
• The data() method now accepts either a string or a file resource containing the message data. (Request #16962)
1.3.4:
• All Net_Socket write failures are now recognized. (Bug #16831)
1.3.3:
• Added getGreeting(), for retrieving the server's greeting string. (Request #16066) [needed for PEAR::Mail]
• We no longer attempt a TLS connection if we're already using a secure socket. (Bug #16254)
• You can now specify a debug output handler via setDebug(). (Request #16420)
1.3.2:
• TLS connection only gets started if no AUTH methods are sent. (Bug #14944)
2010-05-04 08:49:59 +09:00
|
|
|
/**
|
|
|
|
* Return the SMTP server's greeting string.
|
|
|
|
*
|
2016-02-26 21:34:07 +09:00
|
|
|
* @return string A string containing the greeting string, or null if
|
|
|
|
* a greeting has not been received.
|
extlibs updates: PEAR::Mail to 1.2.0, PEAR::Net_SMTP to 1.4.2 (need to go together as a pair)
PEAR::Mail updated to 1.2.0 from 1.1.4, fixes deprecation warnings on PHP 5.3, as well as:
1.2.0:
• QA release - stable.
• Updated minimum dependencies (Net_SMTP, PEAR, PHP)
• Doc Bug #15620 Licence change to BSD
• Bug #13659 Mail parse error in special condition
• Bug #16200 - Security hole allow to read/write Arbitrary File
_hasUnclosedQuotes() doesn't properly handle a double slash before an end quote (slusarz@curecanti.org, Bug #9137).
• Make sure Net_SMTP is defined when calling getSMTPObject() directly (slusarz@curecanti.org, Bug #13772).
• Add addServiceExtensionParameter() to the SMTP driver (slusarz@curecanti.org, Bug #13764).
• Add a method to obtain the Net_SMTP object from the SMTP driver (slusarz@curecanti.org, Bug #13766).
PEAR::Net_SMTP updated to 1.4.2 from 1.3.1, needed to support updated PEAR::Mail:
1.4.2:
• Fixing header string quoting in data(). (Bug #17199)
1.4.1:
• The auth() method now includes an optional $tls parameter that determines whether or not TLS should be attempted (if supported by the PHP runtime and the remote SMTP server). This parameter defaults to true. (Bug #16349)
• Header data can be specified separately from message body data by passing it as the optional second parameter to ``data()``. This is especially useful when an open file resource is being used to supply message data because it allows header fields (like *Subject:*) to be built dynamically at runtime. (Request #17012)
1.4.0:
• The data() method now accepts either a string or a file resource containing the message data. (Request #16962)
1.3.4:
• All Net_Socket write failures are now recognized. (Bug #16831)
1.3.3:
• Added getGreeting(), for retrieving the server's greeting string. (Request #16066) [needed for PEAR::Mail]
• We no longer attempt a TLS connection if we're already using a secure socket. (Bug #16254)
• You can now specify a debug output handler via setDebug(). (Request #16420)
1.3.2:
• TLS connection only gets started if no AUTH methods are sent. (Bug #14944)
2010-05-04 08:49:59 +09:00
|
|
|
*
|
2016-02-26 21:34:07 +09:00
|
|
|
* @since 1.3.3
|
extlibs updates: PEAR::Mail to 1.2.0, PEAR::Net_SMTP to 1.4.2 (need to go together as a pair)
PEAR::Mail updated to 1.2.0 from 1.1.4, fixes deprecation warnings on PHP 5.3, as well as:
1.2.0:
• QA release - stable.
• Updated minimum dependencies (Net_SMTP, PEAR, PHP)
• Doc Bug #15620 Licence change to BSD
• Bug #13659 Mail parse error in special condition
• Bug #16200 - Security hole allow to read/write Arbitrary File
_hasUnclosedQuotes() doesn't properly handle a double slash before an end quote (slusarz@curecanti.org, Bug #9137).
• Make sure Net_SMTP is defined when calling getSMTPObject() directly (slusarz@curecanti.org, Bug #13772).
• Add addServiceExtensionParameter() to the SMTP driver (slusarz@curecanti.org, Bug #13764).
• Add a method to obtain the Net_SMTP object from the SMTP driver (slusarz@curecanti.org, Bug #13766).
PEAR::Net_SMTP updated to 1.4.2 from 1.3.1, needed to support updated PEAR::Mail:
1.4.2:
• Fixing header string quoting in data(). (Bug #17199)
1.4.1:
• The auth() method now includes an optional $tls parameter that determines whether or not TLS should be attempted (if supported by the PHP runtime and the remote SMTP server). This parameter defaults to true. (Bug #16349)
• Header data can be specified separately from message body data by passing it as the optional second parameter to ``data()``. This is especially useful when an open file resource is being used to supply message data because it allows header fields (like *Subject:*) to be built dynamically at runtime. (Request #17012)
1.4.0:
• The data() method now accepts either a string or a file resource containing the message data. (Request #16962)
1.3.4:
• All Net_Socket write failures are now recognized. (Bug #16831)
1.3.3:
• Added getGreeting(), for retrieving the server's greeting string. (Request #16066) [needed for PEAR::Mail]
• We no longer attempt a TLS connection if we're already using a secure socket. (Bug #16254)
• You can now specify a debug output handler via setDebug(). (Request #16420)
1.3.2:
• TLS connection only gets started if no AUTH methods are sent. (Bug #14944)
2010-05-04 08:49:59 +09:00
|
|
|
*/
|
2016-02-26 21:34:07 +09:00
|
|
|
public function getGreeting()
|
extlibs updates: PEAR::Mail to 1.2.0, PEAR::Net_SMTP to 1.4.2 (need to go together as a pair)
PEAR::Mail updated to 1.2.0 from 1.1.4, fixes deprecation warnings on PHP 5.3, as well as:
1.2.0:
• QA release - stable.
• Updated minimum dependencies (Net_SMTP, PEAR, PHP)
• Doc Bug #15620 Licence change to BSD
• Bug #13659 Mail parse error in special condition
• Bug #16200 - Security hole allow to read/write Arbitrary File
_hasUnclosedQuotes() doesn't properly handle a double slash before an end quote (slusarz@curecanti.org, Bug #9137).
• Make sure Net_SMTP is defined when calling getSMTPObject() directly (slusarz@curecanti.org, Bug #13772).
• Add addServiceExtensionParameter() to the SMTP driver (slusarz@curecanti.org, Bug #13764).
• Add a method to obtain the Net_SMTP object from the SMTP driver (slusarz@curecanti.org, Bug #13766).
PEAR::Net_SMTP updated to 1.4.2 from 1.3.1, needed to support updated PEAR::Mail:
1.4.2:
• Fixing header string quoting in data(). (Bug #17199)
1.4.1:
• The auth() method now includes an optional $tls parameter that determines whether or not TLS should be attempted (if supported by the PHP runtime and the remote SMTP server). This parameter defaults to true. (Bug #16349)
• Header data can be specified separately from message body data by passing it as the optional second parameter to ``data()``. This is especially useful when an open file resource is being used to supply message data because it allows header fields (like *Subject:*) to be built dynamically at runtime. (Request #17012)
1.4.0:
• The data() method now accepts either a string or a file resource containing the message data. (Request #16962)
1.3.4:
• All Net_Socket write failures are now recognized. (Bug #16831)
1.3.3:
• Added getGreeting(), for retrieving the server's greeting string. (Request #16066) [needed for PEAR::Mail]
• We no longer attempt a TLS connection if we're already using a secure socket. (Bug #16254)
• You can now specify a debug output handler via setDebug(). (Request #16420)
1.3.2:
• TLS connection only gets started if no AUTH methods are sent. (Bug #14944)
2010-05-04 08:49:59 +09:00
|
|
|
{
|
2016-02-26 21:34:07 +09:00
|
|
|
return $this->greeting;
|
extlibs updates: PEAR::Mail to 1.2.0, PEAR::Net_SMTP to 1.4.2 (need to go together as a pair)
PEAR::Mail updated to 1.2.0 from 1.1.4, fixes deprecation warnings on PHP 5.3, as well as:
1.2.0:
• QA release - stable.
• Updated minimum dependencies (Net_SMTP, PEAR, PHP)
• Doc Bug #15620 Licence change to BSD
• Bug #13659 Mail parse error in special condition
• Bug #16200 - Security hole allow to read/write Arbitrary File
_hasUnclosedQuotes() doesn't properly handle a double slash before an end quote (slusarz@curecanti.org, Bug #9137).
• Make sure Net_SMTP is defined when calling getSMTPObject() directly (slusarz@curecanti.org, Bug #13772).
• Add addServiceExtensionParameter() to the SMTP driver (slusarz@curecanti.org, Bug #13764).
• Add a method to obtain the Net_SMTP object from the SMTP driver (slusarz@curecanti.org, Bug #13766).
PEAR::Net_SMTP updated to 1.4.2 from 1.3.1, needed to support updated PEAR::Mail:
1.4.2:
• Fixing header string quoting in data(). (Bug #17199)
1.4.1:
• The auth() method now includes an optional $tls parameter that determines whether or not TLS should be attempted (if supported by the PHP runtime and the remote SMTP server). This parameter defaults to true. (Bug #16349)
• Header data can be specified separately from message body data by passing it as the optional second parameter to ``data()``. This is especially useful when an open file resource is being used to supply message data because it allows header fields (like *Subject:*) to be built dynamically at runtime. (Request #17012)
1.4.0:
• The data() method now accepts either a string or a file resource containing the message data. (Request #16962)
1.3.4:
• All Net_Socket write failures are now recognized. (Bug #16831)
1.3.3:
• Added getGreeting(), for retrieving the server's greeting string. (Request #16066) [needed for PEAR::Mail]
• We no longer attempt a TLS connection if we're already using a secure socket. (Bug #16254)
• You can now specify a debug output handler via setDebug(). (Request #16420)
1.3.2:
• TLS connection only gets started if no AUTH methods are sent. (Bug #14944)
2010-05-04 08:49:59 +09:00
|
|
|
}
|
|
|
|
|
2008-08-22 22:17:14 +09:00
|
|
|
/**
|
|
|
|
* Attempt to connect to the SMTP server.
|
|
|
|
*
|
2016-02-26 21:34:07 +09:00
|
|
|
* @param int $timeout The timeout value (in seconds) for the
|
|
|
|
* socket connection attempt.
|
|
|
|
* @param bool $persistent Should a persistent socket connection
|
|
|
|
* be used?
|
2008-08-22 22:17:14 +09:00
|
|
|
*
|
|
|
|
* @return mixed Returns a PEAR_Error with an error message on any
|
|
|
|
* kind of failure, or true on success.
|
2016-02-26 21:34:07 +09:00
|
|
|
* @since 1.0
|
2008-08-22 22:17:14 +09:00
|
|
|
*/
|
2016-02-26 21:34:07 +09:00
|
|
|
public function connect($timeout = null, $persistent = false)
|
2008-08-22 22:17:14 +09:00
|
|
|
{
|
2016-02-26 21:34:07 +09:00
|
|
|
$this->greeting = null;
|
|
|
|
|
|
|
|
$result = $this->socket->connect(
|
|
|
|
$this->host, $this->port, $persistent, $timeout, $this->socket_options
|
|
|
|
);
|
|
|
|
|
2008-08-22 22:17:14 +09:00
|
|
|
if (PEAR::isError($result)) {
|
2016-02-26 21:34:07 +09:00
|
|
|
return PEAR::raiseError(
|
|
|
|
'Failed to connect socket: ' . $result->getMessage()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Now that we're connected, reset the socket's timeout value for
|
|
|
|
* future I/O operations. This allows us to have different socket
|
|
|
|
* timeout values for the initial connection (our $timeout parameter)
|
|
|
|
* and all other socket operations.
|
|
|
|
*/
|
|
|
|
if ($this->timeout > 0) {
|
|
|
|
if (PEAR::isError($error = $this->setTimeout($this->timeout))) {
|
|
|
|
return $error;
|
|
|
|
}
|
2008-08-22 22:17:14 +09:00
|
|
|
}
|
|
|
|
|
2016-02-26 21:34:07 +09:00
|
|
|
if (PEAR::isError($error = $this->parseResponse(220))) {
|
2008-08-22 22:17:14 +09:00
|
|
|
return $error;
|
|
|
|
}
|
extlibs updates: PEAR::Mail to 1.2.0, PEAR::Net_SMTP to 1.4.2 (need to go together as a pair)
PEAR::Mail updated to 1.2.0 from 1.1.4, fixes deprecation warnings on PHP 5.3, as well as:
1.2.0:
• QA release - stable.
• Updated minimum dependencies (Net_SMTP, PEAR, PHP)
• Doc Bug #15620 Licence change to BSD
• Bug #13659 Mail parse error in special condition
• Bug #16200 - Security hole allow to read/write Arbitrary File
_hasUnclosedQuotes() doesn't properly handle a double slash before an end quote (slusarz@curecanti.org, Bug #9137).
• Make sure Net_SMTP is defined when calling getSMTPObject() directly (slusarz@curecanti.org, Bug #13772).
• Add addServiceExtensionParameter() to the SMTP driver (slusarz@curecanti.org, Bug #13764).
• Add a method to obtain the Net_SMTP object from the SMTP driver (slusarz@curecanti.org, Bug #13766).
PEAR::Net_SMTP updated to 1.4.2 from 1.3.1, needed to support updated PEAR::Mail:
1.4.2:
• Fixing header string quoting in data(). (Bug #17199)
1.4.1:
• The auth() method now includes an optional $tls parameter that determines whether or not TLS should be attempted (if supported by the PHP runtime and the remote SMTP server). This parameter defaults to true. (Bug #16349)
• Header data can be specified separately from message body data by passing it as the optional second parameter to ``data()``. This is especially useful when an open file resource is being used to supply message data because it allows header fields (like *Subject:*) to be built dynamically at runtime. (Request #17012)
1.4.0:
• The data() method now accepts either a string or a file resource containing the message data. (Request #16962)
1.3.4:
• All Net_Socket write failures are now recognized. (Bug #16831)
1.3.3:
• Added getGreeting(), for retrieving the server's greeting string. (Request #16066) [needed for PEAR::Mail]
• We no longer attempt a TLS connection if we're already using a secure socket. (Bug #16254)
• You can now specify a debug output handler via setDebug(). (Request #16420)
1.3.2:
• TLS connection only gets started if no AUTH methods are sent. (Bug #14944)
2010-05-04 08:49:59 +09:00
|
|
|
|
|
|
|
/* Extract and store a copy of the server's greeting string. */
|
2016-02-26 21:34:07 +09:00
|
|
|
list(, $this->greeting) = $this->getResponse();
|
extlibs updates: PEAR::Mail to 1.2.0, PEAR::Net_SMTP to 1.4.2 (need to go together as a pair)
PEAR::Mail updated to 1.2.0 from 1.1.4, fixes deprecation warnings on PHP 5.3, as well as:
1.2.0:
• QA release - stable.
• Updated minimum dependencies (Net_SMTP, PEAR, PHP)
• Doc Bug #15620 Licence change to BSD
• Bug #13659 Mail parse error in special condition
• Bug #16200 - Security hole allow to read/write Arbitrary File
_hasUnclosedQuotes() doesn't properly handle a double slash before an end quote (slusarz@curecanti.org, Bug #9137).
• Make sure Net_SMTP is defined when calling getSMTPObject() directly (slusarz@curecanti.org, Bug #13772).
• Add addServiceExtensionParameter() to the SMTP driver (slusarz@curecanti.org, Bug #13764).
• Add a method to obtain the Net_SMTP object from the SMTP driver (slusarz@curecanti.org, Bug #13766).
PEAR::Net_SMTP updated to 1.4.2 from 1.3.1, needed to support updated PEAR::Mail:
1.4.2:
• Fixing header string quoting in data(). (Bug #17199)
1.4.1:
• The auth() method now includes an optional $tls parameter that determines whether or not TLS should be attempted (if supported by the PHP runtime and the remote SMTP server). This parameter defaults to true. (Bug #16349)
• Header data can be specified separately from message body data by passing it as the optional second parameter to ``data()``. This is especially useful when an open file resource is being used to supply message data because it allows header fields (like *Subject:*) to be built dynamically at runtime. (Request #17012)
1.4.0:
• The data() method now accepts either a string or a file resource containing the message data. (Request #16962)
1.3.4:
• All Net_Socket write failures are now recognized. (Bug #16831)
1.3.3:
• Added getGreeting(), for retrieving the server's greeting string. (Request #16066) [needed for PEAR::Mail]
• We no longer attempt a TLS connection if we're already using a secure socket. (Bug #16254)
• You can now specify a debug output handler via setDebug(). (Request #16420)
1.3.2:
• TLS connection only gets started if no AUTH methods are sent. (Bug #14944)
2010-05-04 08:49:59 +09:00
|
|
|
|
2016-02-26 21:34:07 +09:00
|
|
|
if (PEAR::isError($error = $this->negotiate())) {
|
2008-08-22 22:17:14 +09:00
|
|
|
return $error;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Attempt to disconnect from the SMTP server.
|
|
|
|
*
|
|
|
|
* @return mixed Returns a PEAR_Error with an error message on any
|
|
|
|
* kind of failure, or true on success.
|
2016-02-26 21:34:07 +09:00
|
|
|
* @since 1.0
|
2008-08-22 22:17:14 +09:00
|
|
|
*/
|
2016-02-26 21:34:07 +09:00
|
|
|
public function disconnect()
|
2008-08-22 22:17:14 +09:00
|
|
|
{
|
2016-02-26 21:34:07 +09:00
|
|
|
if (PEAR::isError($error = $this->put('QUIT'))) {
|
2008-08-22 22:17:14 +09:00
|
|
|
return $error;
|
|
|
|
}
|
2016-02-26 21:34:07 +09:00
|
|
|
if (PEAR::isError($error = $this->parseResponse(221))) {
|
2008-08-22 22:17:14 +09:00
|
|
|
return $error;
|
|
|
|
}
|
2016-02-26 21:34:07 +09:00
|
|
|
if (PEAR::isError($error = $this->socket->disconnect())) {
|
|
|
|
return PEAR::raiseError(
|
|
|
|
'Failed to disconnect socket: ' . $error->getMessage()
|
|
|
|
);
|
2008-08-22 22:17:14 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Attempt to send the EHLO command and obtain a list of ESMTP
|
|
|
|
* extensions available, and failing that just send HELO.
|
|
|
|
*
|
|
|
|
* @return mixed Returns a PEAR_Error with an error message on any
|
|
|
|
* kind of failure, or true on success.
|
|
|
|
*
|
2016-02-26 21:34:07 +09:00
|
|
|
* @since 1.1.0
|
2008-08-22 22:17:14 +09:00
|
|
|
*/
|
2016-02-26 21:34:07 +09:00
|
|
|
protected function negotiate()
|
2008-08-22 22:17:14 +09:00
|
|
|
{
|
2016-02-26 21:34:07 +09:00
|
|
|
if (PEAR::isError($error = $this->put('EHLO', $this->localhost))) {
|
2008-08-22 22:17:14 +09:00
|
|
|
return $error;
|
|
|
|
}
|
|
|
|
|
2016-02-26 21:34:07 +09:00
|
|
|
if (PEAR::isError($this->parseResponse(250))) {
|
2008-08-22 22:17:14 +09:00
|
|
|
/* If the EHLO failed, try the simpler HELO command. */
|
2016-02-26 21:34:07 +09:00
|
|
|
if (PEAR::isError($error = $this->put('HELO', $this->localhost))) {
|
2008-08-22 22:17:14 +09:00
|
|
|
return $error;
|
|
|
|
}
|
2016-02-26 21:34:07 +09:00
|
|
|
if (PEAR::isError($this->parseResponse(250))) {
|
|
|
|
return PEAR::raiseError('HELO was not accepted', $this->code);
|
2008-08-22 22:17:14 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-02-26 21:34:07 +09:00
|
|
|
foreach ($this->arguments as $argument) {
|
|
|
|
$verb = strtok($argument, ' ');
|
|
|
|
$len = strlen($verb);
|
|
|
|
$arguments = substr($argument, $len + 1, strlen($argument) - $len - 1);
|
|
|
|
$this->esmtp[$verb] = $arguments;
|
2008-08-22 22:17:14 +09:00
|
|
|
}
|
|
|
|
|
2016-02-26 21:34:07 +09:00
|
|
|
if (!isset($this->esmtp['PIPELINING'])) {
|
2008-08-22 22:17:14 +09:00
|
|
|
$this->pipelining = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the name of the best authentication method that the server
|
|
|
|
* has advertised.
|
|
|
|
*
|
2016-02-26 21:34:07 +09:00
|
|
|
* @return mixed Returns a string containing the name of the best
|
|
|
|
* supported authentication method or a PEAR_Error object
|
|
|
|
* if a failure condition is encountered.
|
|
|
|
* @since 1.1.0
|
2008-08-22 22:17:14 +09:00
|
|
|
*/
|
2016-02-26 21:34:07 +09:00
|
|
|
protected function getBestAuthMethod()
|
2008-08-22 22:17:14 +09:00
|
|
|
{
|
2016-02-26 21:34:07 +09:00
|
|
|
$available_methods = explode(' ', $this->esmtp['AUTH']);
|
2008-08-22 22:17:14 +09:00
|
|
|
|
2016-02-26 21:34:07 +09:00
|
|
|
foreach ($this->auth_methods as $method => $callback) {
|
2008-08-22 22:17:14 +09:00
|
|
|
if (in_array($method, $available_methods)) {
|
|
|
|
return $method;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return PEAR::raiseError('No supported authentication methods');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Attempt to do SMTP authentication.
|
|
|
|
*
|
2016-02-26 21:34:07 +09:00
|
|
|
* @param string $uid The userid to authenticate as.
|
|
|
|
* @param string $pwd The password to authenticate with.
|
|
|
|
* @param string $method The requested authentication method. If none is
|
|
|
|
* specified, the best supported method will be used.
|
|
|
|
* @param bool $tls Flag indicating whether or not TLS should be attempted.
|
|
|
|
* @param string $authz An optional authorization identifier. If specified, this
|
|
|
|
* identifier will be used as the authorization proxy.
|
2008-08-22 22:17:14 +09:00
|
|
|
*
|
|
|
|
* @return mixed Returns a PEAR_Error with an error message on any
|
|
|
|
* kind of failure, or true on success.
|
2016-02-26 21:34:07 +09:00
|
|
|
* @since 1.0
|
2008-08-22 22:17:14 +09:00
|
|
|
*/
|
2016-02-26 21:34:07 +09:00
|
|
|
public function auth($uid, $pwd , $method = '', $tls = true, $authz = '')
|
2008-08-22 22:17:14 +09:00
|
|
|
{
|
extlibs updates: PEAR::Mail to 1.2.0, PEAR::Net_SMTP to 1.4.2 (need to go together as a pair)
PEAR::Mail updated to 1.2.0 from 1.1.4, fixes deprecation warnings on PHP 5.3, as well as:
1.2.0:
• QA release - stable.
• Updated minimum dependencies (Net_SMTP, PEAR, PHP)
• Doc Bug #15620 Licence change to BSD
• Bug #13659 Mail parse error in special condition
• Bug #16200 - Security hole allow to read/write Arbitrary File
_hasUnclosedQuotes() doesn't properly handle a double slash before an end quote (slusarz@curecanti.org, Bug #9137).
• Make sure Net_SMTP is defined when calling getSMTPObject() directly (slusarz@curecanti.org, Bug #13772).
• Add addServiceExtensionParameter() to the SMTP driver (slusarz@curecanti.org, Bug #13764).
• Add a method to obtain the Net_SMTP object from the SMTP driver (slusarz@curecanti.org, Bug #13766).
PEAR::Net_SMTP updated to 1.4.2 from 1.3.1, needed to support updated PEAR::Mail:
1.4.2:
• Fixing header string quoting in data(). (Bug #17199)
1.4.1:
• The auth() method now includes an optional $tls parameter that determines whether or not TLS should be attempted (if supported by the PHP runtime and the remote SMTP server). This parameter defaults to true. (Bug #16349)
• Header data can be specified separately from message body data by passing it as the optional second parameter to ``data()``. This is especially useful when an open file resource is being used to supply message data because it allows header fields (like *Subject:*) to be built dynamically at runtime. (Request #17012)
1.4.0:
• The data() method now accepts either a string or a file resource containing the message data. (Request #16962)
1.3.4:
• All Net_Socket write failures are now recognized. (Bug #16831)
1.3.3:
• Added getGreeting(), for retrieving the server's greeting string. (Request #16066) [needed for PEAR::Mail]
• We no longer attempt a TLS connection if we're already using a secure socket. (Bug #16254)
• You can now specify a debug output handler via setDebug(). (Request #16420)
1.3.2:
• TLS connection only gets started if no AUTH methods are sent. (Bug #14944)
2010-05-04 08:49:59 +09:00
|
|
|
/* We can only attempt a TLS connection if one has been requested,
|
2016-02-26 21:34:07 +09:00
|
|
|
* we're running PHP 5.1.0 or later, have access to the OpenSSL
|
|
|
|
* extension, are connected to an SMTP server which supports the
|
|
|
|
* STARTTLS extension, and aren't already connected over a secure
|
extlibs updates: PEAR::Mail to 1.2.0, PEAR::Net_SMTP to 1.4.2 (need to go together as a pair)
PEAR::Mail updated to 1.2.0 from 1.1.4, fixes deprecation warnings on PHP 5.3, as well as:
1.2.0:
• QA release - stable.
• Updated minimum dependencies (Net_SMTP, PEAR, PHP)
• Doc Bug #15620 Licence change to BSD
• Bug #13659 Mail parse error in special condition
• Bug #16200 - Security hole allow to read/write Arbitrary File
_hasUnclosedQuotes() doesn't properly handle a double slash before an end quote (slusarz@curecanti.org, Bug #9137).
• Make sure Net_SMTP is defined when calling getSMTPObject() directly (slusarz@curecanti.org, Bug #13772).
• Add addServiceExtensionParameter() to the SMTP driver (slusarz@curecanti.org, Bug #13764).
• Add a method to obtain the Net_SMTP object from the SMTP driver (slusarz@curecanti.org, Bug #13766).
PEAR::Net_SMTP updated to 1.4.2 from 1.3.1, needed to support updated PEAR::Mail:
1.4.2:
• Fixing header string quoting in data(). (Bug #17199)
1.4.1:
• The auth() method now includes an optional $tls parameter that determines whether or not TLS should be attempted (if supported by the PHP runtime and the remote SMTP server). This parameter defaults to true. (Bug #16349)
• Header data can be specified separately from message body data by passing it as the optional second parameter to ``data()``. This is especially useful when an open file resource is being used to supply message data because it allows header fields (like *Subject:*) to be built dynamically at runtime. (Request #17012)
1.4.0:
• The data() method now accepts either a string or a file resource containing the message data. (Request #16962)
1.3.4:
• All Net_Socket write failures are now recognized. (Bug #16831)
1.3.3:
• Added getGreeting(), for retrieving the server's greeting string. (Request #16066) [needed for PEAR::Mail]
• We no longer attempt a TLS connection if we're already using a secure socket. (Bug #16254)
• You can now specify a debug output handler via setDebug(). (Request #16420)
1.3.2:
• TLS connection only gets started if no AUTH methods are sent. (Bug #14944)
2010-05-04 08:49:59 +09:00
|
|
|
* (SSL) socket connection. */
|
2016-02-26 21:34:07 +09:00
|
|
|
if ($tls && version_compare(PHP_VERSION, '5.1.0', '>=')
|
|
|
|
&& extension_loaded('openssl') && isset($this->esmtp['STARTTLS'])
|
|
|
|
&& strncasecmp($this->host, 'ssl://', 6) !== 0
|
|
|
|
) {
|
extlibs updates: PEAR::Mail to 1.2.0, PEAR::Net_SMTP to 1.4.2 (need to go together as a pair)
PEAR::Mail updated to 1.2.0 from 1.1.4, fixes deprecation warnings on PHP 5.3, as well as:
1.2.0:
• QA release - stable.
• Updated minimum dependencies (Net_SMTP, PEAR, PHP)
• Doc Bug #15620 Licence change to BSD
• Bug #13659 Mail parse error in special condition
• Bug #16200 - Security hole allow to read/write Arbitrary File
_hasUnclosedQuotes() doesn't properly handle a double slash before an end quote (slusarz@curecanti.org, Bug #9137).
• Make sure Net_SMTP is defined when calling getSMTPObject() directly (slusarz@curecanti.org, Bug #13772).
• Add addServiceExtensionParameter() to the SMTP driver (slusarz@curecanti.org, Bug #13764).
• Add a method to obtain the Net_SMTP object from the SMTP driver (slusarz@curecanti.org, Bug #13766).
PEAR::Net_SMTP updated to 1.4.2 from 1.3.1, needed to support updated PEAR::Mail:
1.4.2:
• Fixing header string quoting in data(). (Bug #17199)
1.4.1:
• The auth() method now includes an optional $tls parameter that determines whether or not TLS should be attempted (if supported by the PHP runtime and the remote SMTP server). This parameter defaults to true. (Bug #16349)
• Header data can be specified separately from message body data by passing it as the optional second parameter to ``data()``. This is especially useful when an open file resource is being used to supply message data because it allows header fields (like *Subject:*) to be built dynamically at runtime. (Request #17012)
1.4.0:
• The data() method now accepts either a string or a file resource containing the message data. (Request #16962)
1.3.4:
• All Net_Socket write failures are now recognized. (Bug #16831)
1.3.3:
• Added getGreeting(), for retrieving the server's greeting string. (Request #16066) [needed for PEAR::Mail]
• We no longer attempt a TLS connection if we're already using a secure socket. (Bug #16254)
• You can now specify a debug output handler via setDebug(). (Request #16420)
1.3.2:
• TLS connection only gets started if no AUTH methods are sent. (Bug #14944)
2010-05-04 08:49:59 +09:00
|
|
|
/* Start the TLS connection attempt. */
|
2016-02-26 21:34:07 +09:00
|
|
|
if (PEAR::isError($result = $this->put('STARTTLS'))) {
|
extlibs updates: PEAR::Mail to 1.2.0, PEAR::Net_SMTP to 1.4.2 (need to go together as a pair)
PEAR::Mail updated to 1.2.0 from 1.1.4, fixes deprecation warnings on PHP 5.3, as well as:
1.2.0:
• QA release - stable.
• Updated minimum dependencies (Net_SMTP, PEAR, PHP)
• Doc Bug #15620 Licence change to BSD
• Bug #13659 Mail parse error in special condition
• Bug #16200 - Security hole allow to read/write Arbitrary File
_hasUnclosedQuotes() doesn't properly handle a double slash before an end quote (slusarz@curecanti.org, Bug #9137).
• Make sure Net_SMTP is defined when calling getSMTPObject() directly (slusarz@curecanti.org, Bug #13772).
• Add addServiceExtensionParameter() to the SMTP driver (slusarz@curecanti.org, Bug #13764).
• Add a method to obtain the Net_SMTP object from the SMTP driver (slusarz@curecanti.org, Bug #13766).
PEAR::Net_SMTP updated to 1.4.2 from 1.3.1, needed to support updated PEAR::Mail:
1.4.2:
• Fixing header string quoting in data(). (Bug #17199)
1.4.1:
• The auth() method now includes an optional $tls parameter that determines whether or not TLS should be attempted (if supported by the PHP runtime and the remote SMTP server). This parameter defaults to true. (Bug #16349)
• Header data can be specified separately from message body data by passing it as the optional second parameter to ``data()``. This is especially useful when an open file resource is being used to supply message data because it allows header fields (like *Subject:*) to be built dynamically at runtime. (Request #17012)
1.4.0:
• The data() method now accepts either a string or a file resource containing the message data. (Request #16962)
1.3.4:
• All Net_Socket write failures are now recognized. (Bug #16831)
1.3.3:
• Added getGreeting(), for retrieving the server's greeting string. (Request #16066) [needed for PEAR::Mail]
• We no longer attempt a TLS connection if we're already using a secure socket. (Bug #16254)
• You can now specify a debug output handler via setDebug(). (Request #16420)
1.3.2:
• TLS connection only gets started if no AUTH methods are sent. (Bug #14944)
2010-05-04 08:49:59 +09:00
|
|
|
return $result;
|
|
|
|
}
|
2016-02-26 21:34:07 +09:00
|
|
|
if (PEAR::isError($result = $this->parseResponse(220))) {
|
extlibs updates: PEAR::Mail to 1.2.0, PEAR::Net_SMTP to 1.4.2 (need to go together as a pair)
PEAR::Mail updated to 1.2.0 from 1.1.4, fixes deprecation warnings on PHP 5.3, as well as:
1.2.0:
• QA release - stable.
• Updated minimum dependencies (Net_SMTP, PEAR, PHP)
• Doc Bug #15620 Licence change to BSD
• Bug #13659 Mail parse error in special condition
• Bug #16200 - Security hole allow to read/write Arbitrary File
_hasUnclosedQuotes() doesn't properly handle a double slash before an end quote (slusarz@curecanti.org, Bug #9137).
• Make sure Net_SMTP is defined when calling getSMTPObject() directly (slusarz@curecanti.org, Bug #13772).
• Add addServiceExtensionParameter() to the SMTP driver (slusarz@curecanti.org, Bug #13764).
• Add a method to obtain the Net_SMTP object from the SMTP driver (slusarz@curecanti.org, Bug #13766).
PEAR::Net_SMTP updated to 1.4.2 from 1.3.1, needed to support updated PEAR::Mail:
1.4.2:
• Fixing header string quoting in data(). (Bug #17199)
1.4.1:
• The auth() method now includes an optional $tls parameter that determines whether or not TLS should be attempted (if supported by the PHP runtime and the remote SMTP server). This parameter defaults to true. (Bug #16349)
• Header data can be specified separately from message body data by passing it as the optional second parameter to ``data()``. This is especially useful when an open file resource is being used to supply message data because it allows header fields (like *Subject:*) to be built dynamically at runtime. (Request #17012)
1.4.0:
• The data() method now accepts either a string or a file resource containing the message data. (Request #16962)
1.3.4:
• All Net_Socket write failures are now recognized. (Bug #16831)
1.3.3:
• Added getGreeting(), for retrieving the server's greeting string. (Request #16066) [needed for PEAR::Mail]
• We no longer attempt a TLS connection if we're already using a secure socket. (Bug #16254)
• You can now specify a debug output handler via setDebug(). (Request #16420)
1.3.2:
• TLS connection only gets started if no AUTH methods are sent. (Bug #14944)
2010-05-04 08:49:59 +09:00
|
|
|
return $result;
|
|
|
|
}
|
2016-02-26 21:34:07 +09:00
|
|
|
if (isset($this->socket_options['ssl']['crypto_method'])) {
|
|
|
|
$crypto_method = $this->socket_options['ssl']['crypto_method'];
|
|
|
|
} else {
|
|
|
|
/* STREAM_CRYPTO_METHOD_TLS_ANY_CLIENT constant does not exist
|
|
|
|
* and STREAM_CRYPTO_METHOD_SSLv23_CLIENT constant is
|
|
|
|
* inconsistent across PHP versions. */
|
|
|
|
$crypto_method = STREAM_CRYPTO_METHOD_TLS_CLIENT
|
|
|
|
| @STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT
|
|
|
|
| @STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT;
|
|
|
|
}
|
|
|
|
if (PEAR::isError($result = $this->socket->enableCrypto(true, $crypto_method))) {
|
extlibs updates: PEAR::Mail to 1.2.0, PEAR::Net_SMTP to 1.4.2 (need to go together as a pair)
PEAR::Mail updated to 1.2.0 from 1.1.4, fixes deprecation warnings on PHP 5.3, as well as:
1.2.0:
• QA release - stable.
• Updated minimum dependencies (Net_SMTP, PEAR, PHP)
• Doc Bug #15620 Licence change to BSD
• Bug #13659 Mail parse error in special condition
• Bug #16200 - Security hole allow to read/write Arbitrary File
_hasUnclosedQuotes() doesn't properly handle a double slash before an end quote (slusarz@curecanti.org, Bug #9137).
• Make sure Net_SMTP is defined when calling getSMTPObject() directly (slusarz@curecanti.org, Bug #13772).
• Add addServiceExtensionParameter() to the SMTP driver (slusarz@curecanti.org, Bug #13764).
• Add a method to obtain the Net_SMTP object from the SMTP driver (slusarz@curecanti.org, Bug #13766).
PEAR::Net_SMTP updated to 1.4.2 from 1.3.1, needed to support updated PEAR::Mail:
1.4.2:
• Fixing header string quoting in data(). (Bug #17199)
1.4.1:
• The auth() method now includes an optional $tls parameter that determines whether or not TLS should be attempted (if supported by the PHP runtime and the remote SMTP server). This parameter defaults to true. (Bug #16349)
• Header data can be specified separately from message body data by passing it as the optional second parameter to ``data()``. This is especially useful when an open file resource is being used to supply message data because it allows header fields (like *Subject:*) to be built dynamically at runtime. (Request #17012)
1.4.0:
• The data() method now accepts either a string or a file resource containing the message data. (Request #16962)
1.3.4:
• All Net_Socket write failures are now recognized. (Bug #16831)
1.3.3:
• Added getGreeting(), for retrieving the server's greeting string. (Request #16066) [needed for PEAR::Mail]
• We no longer attempt a TLS connection if we're already using a secure socket. (Bug #16254)
• You can now specify a debug output handler via setDebug(). (Request #16420)
1.3.2:
• TLS connection only gets started if no AUTH methods are sent. (Bug #14944)
2010-05-04 08:49:59 +09:00
|
|
|
return $result;
|
|
|
|
} elseif ($result !== true) {
|
|
|
|
return PEAR::raiseError('STARTTLS failed');
|
2008-08-22 22:17:14 +09:00
|
|
|
}
|
extlibs updates: PEAR::Mail to 1.2.0, PEAR::Net_SMTP to 1.4.2 (need to go together as a pair)
PEAR::Mail updated to 1.2.0 from 1.1.4, fixes deprecation warnings on PHP 5.3, as well as:
1.2.0:
• QA release - stable.
• Updated minimum dependencies (Net_SMTP, PEAR, PHP)
• Doc Bug #15620 Licence change to BSD
• Bug #13659 Mail parse error in special condition
• Bug #16200 - Security hole allow to read/write Arbitrary File
_hasUnclosedQuotes() doesn't properly handle a double slash before an end quote (slusarz@curecanti.org, Bug #9137).
• Make sure Net_SMTP is defined when calling getSMTPObject() directly (slusarz@curecanti.org, Bug #13772).
• Add addServiceExtensionParameter() to the SMTP driver (slusarz@curecanti.org, Bug #13764).
• Add a method to obtain the Net_SMTP object from the SMTP driver (slusarz@curecanti.org, Bug #13766).
PEAR::Net_SMTP updated to 1.4.2 from 1.3.1, needed to support updated PEAR::Mail:
1.4.2:
• Fixing header string quoting in data(). (Bug #17199)
1.4.1:
• The auth() method now includes an optional $tls parameter that determines whether or not TLS should be attempted (if supported by the PHP runtime and the remote SMTP server). This parameter defaults to true. (Bug #16349)
• Header data can be specified separately from message body data by passing it as the optional second parameter to ``data()``. This is especially useful when an open file resource is being used to supply message data because it allows header fields (like *Subject:*) to be built dynamically at runtime. (Request #17012)
1.4.0:
• The data() method now accepts either a string or a file resource containing the message data. (Request #16962)
1.3.4:
• All Net_Socket write failures are now recognized. (Bug #16831)
1.3.3:
• Added getGreeting(), for retrieving the server's greeting string. (Request #16066) [needed for PEAR::Mail]
• We no longer attempt a TLS connection if we're already using a secure socket. (Bug #16254)
• You can now specify a debug output handler via setDebug(). (Request #16420)
1.3.2:
• TLS connection only gets started if no AUTH methods are sent. (Bug #14944)
2010-05-04 08:49:59 +09:00
|
|
|
|
|
|
|
/* Send EHLO again to recieve the AUTH string from the
|
|
|
|
* SMTP server. */
|
2016-02-26 21:34:07 +09:00
|
|
|
$this->negotiate();
|
extlibs updates: PEAR::Mail to 1.2.0, PEAR::Net_SMTP to 1.4.2 (need to go together as a pair)
PEAR::Mail updated to 1.2.0 from 1.1.4, fixes deprecation warnings on PHP 5.3, as well as:
1.2.0:
• QA release - stable.
• Updated minimum dependencies (Net_SMTP, PEAR, PHP)
• Doc Bug #15620 Licence change to BSD
• Bug #13659 Mail parse error in special condition
• Bug #16200 - Security hole allow to read/write Arbitrary File
_hasUnclosedQuotes() doesn't properly handle a double slash before an end quote (slusarz@curecanti.org, Bug #9137).
• Make sure Net_SMTP is defined when calling getSMTPObject() directly (slusarz@curecanti.org, Bug #13772).
• Add addServiceExtensionParameter() to the SMTP driver (slusarz@curecanti.org, Bug #13764).
• Add a method to obtain the Net_SMTP object from the SMTP driver (slusarz@curecanti.org, Bug #13766).
PEAR::Net_SMTP updated to 1.4.2 from 1.3.1, needed to support updated PEAR::Mail:
1.4.2:
• Fixing header string quoting in data(). (Bug #17199)
1.4.1:
• The auth() method now includes an optional $tls parameter that determines whether or not TLS should be attempted (if supported by the PHP runtime and the remote SMTP server). This parameter defaults to true. (Bug #16349)
• Header data can be specified separately from message body data by passing it as the optional second parameter to ``data()``. This is especially useful when an open file resource is being used to supply message data because it allows header fields (like *Subject:*) to be built dynamically at runtime. (Request #17012)
1.4.0:
• The data() method now accepts either a string or a file resource containing the message data. (Request #16962)
1.3.4:
• All Net_Socket write failures are now recognized. (Bug #16831)
1.3.3:
• Added getGreeting(), for retrieving the server's greeting string. (Request #16066) [needed for PEAR::Mail]
• We no longer attempt a TLS connection if we're already using a secure socket. (Bug #16254)
• You can now specify a debug output handler via setDebug(). (Request #16420)
1.3.2:
• TLS connection only gets started if no AUTH methods are sent. (Bug #14944)
2010-05-04 08:49:59 +09:00
|
|
|
}
|
|
|
|
|
2016-02-26 21:34:07 +09:00
|
|
|
if (empty($this->esmtp['AUTH'])) {
|
extlibs updates: PEAR::Mail to 1.2.0, PEAR::Net_SMTP to 1.4.2 (need to go together as a pair)
PEAR::Mail updated to 1.2.0 from 1.1.4, fixes deprecation warnings on PHP 5.3, as well as:
1.2.0:
• QA release - stable.
• Updated minimum dependencies (Net_SMTP, PEAR, PHP)
• Doc Bug #15620 Licence change to BSD
• Bug #13659 Mail parse error in special condition
• Bug #16200 - Security hole allow to read/write Arbitrary File
_hasUnclosedQuotes() doesn't properly handle a double slash before an end quote (slusarz@curecanti.org, Bug #9137).
• Make sure Net_SMTP is defined when calling getSMTPObject() directly (slusarz@curecanti.org, Bug #13772).
• Add addServiceExtensionParameter() to the SMTP driver (slusarz@curecanti.org, Bug #13764).
• Add a method to obtain the Net_SMTP object from the SMTP driver (slusarz@curecanti.org, Bug #13766).
PEAR::Net_SMTP updated to 1.4.2 from 1.3.1, needed to support updated PEAR::Mail:
1.4.2:
• Fixing header string quoting in data(). (Bug #17199)
1.4.1:
• The auth() method now includes an optional $tls parameter that determines whether or not TLS should be attempted (if supported by the PHP runtime and the remote SMTP server). This parameter defaults to true. (Bug #16349)
• Header data can be specified separately from message body data by passing it as the optional second parameter to ``data()``. This is especially useful when an open file resource is being used to supply message data because it allows header fields (like *Subject:*) to be built dynamically at runtime. (Request #17012)
1.4.0:
• The data() method now accepts either a string or a file resource containing the message data. (Request #16962)
1.3.4:
• All Net_Socket write failures are now recognized. (Bug #16831)
1.3.3:
• Added getGreeting(), for retrieving the server's greeting string. (Request #16066) [needed for PEAR::Mail]
• We no longer attempt a TLS connection if we're already using a secure socket. (Bug #16254)
• You can now specify a debug output handler via setDebug(). (Request #16420)
1.3.2:
• TLS connection only gets started if no AUTH methods are sent. (Bug #14944)
2010-05-04 08:49:59 +09:00
|
|
|
return PEAR::raiseError('SMTP server does not support authentication');
|
2008-08-22 22:17:14 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
/* If no method has been specified, get the name of the best
|
|
|
|
* supported method advertised by the SMTP server. */
|
|
|
|
if (empty($method)) {
|
2016-02-26 21:34:07 +09:00
|
|
|
if (PEAR::isError($method = $this->getBestAuthMethod())) {
|
2008-08-22 22:17:14 +09:00
|
|
|
/* Return the PEAR_Error object from _getBestAuthMethod(). */
|
|
|
|
return $method;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$method = strtoupper($method);
|
2016-02-26 21:34:07 +09:00
|
|
|
if (!array_key_exists($method, $this->auth_methods)) {
|
2008-08-22 22:17:14 +09:00
|
|
|
return PEAR::raiseError("$method is not a supported authentication method");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-26 21:34:07 +09:00
|
|
|
if (!isset($this->auth_methods[$method])) {
|
|
|
|
return PEAR::raiseError("$method is not a supported authentication method");
|
|
|
|
}
|
2008-08-22 22:17:14 +09:00
|
|
|
|
2016-02-26 21:34:07 +09:00
|
|
|
if (!is_callable($this->auth_methods[$method], false)) {
|
|
|
|
return PEAR::raiseError("$method authentication method cannot be called");
|
|
|
|
}
|
2008-08-22 22:17:14 +09:00
|
|
|
|
2016-02-26 21:34:07 +09:00
|
|
|
if (is_array($this->auth_methods[$method])) {
|
|
|
|
list($object, $method) = $this->auth_methods[$method];
|
|
|
|
$result = $object->{$method}($uid, $pwd, $authz, $this);
|
|
|
|
} else {
|
|
|
|
$func = $this->auth_methods[$method];
|
|
|
|
$result = $func($uid, $pwd, $authz, $this);
|
2008-08-22 22:17:14 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
/* If an error was encountered, return the PEAR_Error object. */
|
|
|
|
if (PEAR::isError($result)) {
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-02-26 21:34:07 +09:00
|
|
|
/**
|
|
|
|
* Add a new authentication method.
|
|
|
|
*
|
|
|
|
* @param string $name The authentication method name (e.g. 'PLAIN')
|
|
|
|
* @param mixed $callback The authentication callback (given as the name of a
|
|
|
|
* function or as an (object, method name) array).
|
|
|
|
* @param bool $prepend Should the new method be prepended to the list of
|
|
|
|
* available methods? This is the default behavior,
|
|
|
|
* giving the new method the highest priority.
|
|
|
|
*
|
|
|
|
* @return mixed True on success or a PEAR_Error object on failure.
|
|
|
|
*
|
|
|
|
* @since 1.6.0
|
|
|
|
*/
|
|
|
|
public function setAuthMethod($name, $callback, $prepend = true)
|
|
|
|
{
|
|
|
|
if (!is_string($name)) {
|
|
|
|
return PEAR::raiseError('Method name is not a string');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!is_string($callback) && !is_array($callback)) {
|
|
|
|
return PEAR::raiseError('Method callback must be string or array');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (is_array($callback)) {
|
|
|
|
if (!is_object($callback[0]) || !is_string($callback[1])) {
|
|
|
|
return PEAR::raiseError('Bad mMethod callback array');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($prepend) {
|
|
|
|
$this->auth_methods = array_merge(
|
|
|
|
array($name => $callback), $this->auth_methods
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
$this->auth_methods[$name] = $callback;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2008-08-22 22:17:14 +09:00
|
|
|
/**
|
|
|
|
* Authenticates the user using the DIGEST-MD5 method.
|
|
|
|
*
|
2016-02-26 21:34:07 +09:00
|
|
|
* @param string $uid The userid to authenticate as.
|
|
|
|
* @param string $pwd The password to authenticate with.
|
|
|
|
* @param string $authz The optional authorization proxy identifier.
|
2008-08-22 22:17:14 +09:00
|
|
|
*
|
|
|
|
* @return mixed Returns a PEAR_Error with an error message on any
|
|
|
|
* kind of failure, or true on success.
|
2016-02-26 21:34:07 +09:00
|
|
|
* @since 1.1.0
|
2008-08-22 22:17:14 +09:00
|
|
|
*/
|
2016-02-26 21:34:07 +09:00
|
|
|
protected function authDigestMD5($uid, $pwd, $authz = '')
|
2008-08-22 22:17:14 +09:00
|
|
|
{
|
2016-02-26 21:34:07 +09:00
|
|
|
if (PEAR::isError($error = $this->put('AUTH', 'DIGEST-MD5'))) {
|
2008-08-22 22:17:14 +09:00
|
|
|
return $error;
|
|
|
|
}
|
|
|
|
/* 334: Continue authentication request */
|
2016-02-26 21:34:07 +09:00
|
|
|
if (PEAR::isError($error = $this->parseResponse(334))) {
|
2008-08-22 22:17:14 +09:00
|
|
|
/* 503: Error: already authenticated */
|
2016-02-26 21:34:07 +09:00
|
|
|
if ($this->code === 503) {
|
2008-08-22 22:17:14 +09:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return $error;
|
|
|
|
}
|
|
|
|
|
2016-02-26 21:34:07 +09:00
|
|
|
$digest = Auth_SASL::factory('digest-md5');
|
|
|
|
$challenge = base64_decode($this->arguments[0]);
|
|
|
|
$auth_str = base64_encode(
|
|
|
|
$digest->getResponse($uid, $pwd, $challenge, $this->host, "smtp", $authz)
|
|
|
|
);
|
2008-08-22 22:17:14 +09:00
|
|
|
|
2016-02-26 21:34:07 +09:00
|
|
|
if (PEAR::isError($error = $this->put($auth_str))) {
|
2008-08-22 22:17:14 +09:00
|
|
|
return $error;
|
|
|
|
}
|
|
|
|
/* 334: Continue authentication request */
|
2016-02-26 21:34:07 +09:00
|
|
|
if (PEAR::isError($error = $this->parseResponse(334))) {
|
2008-08-22 22:17:14 +09:00
|
|
|
return $error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We don't use the protocol's third step because SMTP doesn't
|
|
|
|
* allow subsequent authentication, so we just silently ignore
|
|
|
|
* it. */
|
2016-02-26 21:34:07 +09:00
|
|
|
if (PEAR::isError($error = $this->put(''))) {
|
2008-08-22 22:17:14 +09:00
|
|
|
return $error;
|
|
|
|
}
|
|
|
|
/* 235: Authentication successful */
|
2016-02-26 21:34:07 +09:00
|
|
|
if (PEAR::isError($error = $this->parseResponse(235))) {
|
2008-08-22 22:17:14 +09:00
|
|
|
return $error;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Authenticates the user using the CRAM-MD5 method.
|
|
|
|
*
|
2016-02-26 21:34:07 +09:00
|
|
|
* @param string $uid The userid to authenticate as.
|
|
|
|
* @param string $pwd The password to authenticate with.
|
|
|
|
* @param string $authz The optional authorization proxy identifier.
|
2008-08-22 22:17:14 +09:00
|
|
|
*
|
|
|
|
* @return mixed Returns a PEAR_Error with an error message on any
|
|
|
|
* kind of failure, or true on success.
|
2016-02-26 21:34:07 +09:00
|
|
|
* @since 1.1.0
|
2008-08-22 22:17:14 +09:00
|
|
|
*/
|
2016-02-26 21:34:07 +09:00
|
|
|
protected function authCRAMMD5($uid, $pwd, $authz = '')
|
2008-08-22 22:17:14 +09:00
|
|
|
{
|
2016-02-26 21:34:07 +09:00
|
|
|
if (PEAR::isError($error = $this->put('AUTH', 'CRAM-MD5'))) {
|
2008-08-22 22:17:14 +09:00
|
|
|
return $error;
|
|
|
|
}
|
|
|
|
/* 334: Continue authentication request */
|
2016-02-26 21:34:07 +09:00
|
|
|
if (PEAR::isError($error = $this->parseResponse(334))) {
|
2008-08-22 22:17:14 +09:00
|
|
|
/* 503: Error: already authenticated */
|
2016-02-26 21:34:07 +09:00
|
|
|
if ($this->code === 503) {
|
2008-08-22 22:17:14 +09:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return $error;
|
|
|
|
}
|
|
|
|
|
2016-02-26 21:34:07 +09:00
|
|
|
$challenge = base64_decode($this->arguments[0]);
|
|
|
|
$cram = Auth_SASL::factory('cram-md5');
|
|
|
|
$auth_str = base64_encode($cram->getResponse($uid, $pwd, $challenge));
|
2008-08-22 22:17:14 +09:00
|
|
|
|
2016-02-26 21:34:07 +09:00
|
|
|
if (PEAR::isError($error = $this->put($auth_str))) {
|
2008-08-22 22:17:14 +09:00
|
|
|
return $error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 235: Authentication successful */
|
2016-02-26 21:34:07 +09:00
|
|
|
if (PEAR::isError($error = $this->parseResponse(235))) {
|
2008-08-22 22:17:14 +09:00
|
|
|
return $error;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Authenticates the user using the LOGIN method.
|
|
|
|
*
|
2016-02-26 21:34:07 +09:00
|
|
|
* @param string $uid The userid to authenticate as.
|
|
|
|
* @param string $pwd The password to authenticate with.
|
|
|
|
* @param string $authz The optional authorization proxy identifier.
|
2008-08-22 22:17:14 +09:00
|
|
|
*
|
|
|
|
* @return mixed Returns a PEAR_Error with an error message on any
|
|
|
|
* kind of failure, or true on success.
|
2016-02-26 21:34:07 +09:00
|
|
|
* @since 1.1.0
|
2008-08-22 22:17:14 +09:00
|
|
|
*/
|
2016-02-26 21:34:07 +09:00
|
|
|
protected function authLogin($uid, $pwd, $authz = '')
|
2008-08-22 22:17:14 +09:00
|
|
|
{
|
2016-02-26 21:34:07 +09:00
|
|
|
if (PEAR::isError($error = $this->put('AUTH', 'LOGIN'))) {
|
2008-08-22 22:17:14 +09:00
|
|
|
return $error;
|
|
|
|
}
|
|
|
|
/* 334: Continue authentication request */
|
2016-02-26 21:34:07 +09:00
|
|
|
if (PEAR::isError($error = $this->parseResponse(334))) {
|
2008-08-22 22:17:14 +09:00
|
|
|
/* 503: Error: already authenticated */
|
2016-02-26 21:34:07 +09:00
|
|
|
if ($this->code === 503) {
|
2008-08-22 22:17:14 +09:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return $error;
|
|
|
|
}
|
|
|
|
|
2016-02-26 21:34:07 +09:00
|
|
|
if (PEAR::isError($error = $this->put(base64_encode($uid)))) {
|
2008-08-22 22:17:14 +09:00
|
|
|
return $error;
|
|
|
|
}
|
|
|
|
/* 334: Continue authentication request */
|
2016-02-26 21:34:07 +09:00
|
|
|
if (PEAR::isError($error = $this->parseResponse(334))) {
|
2008-08-22 22:17:14 +09:00
|
|
|
return $error;
|
|
|
|
}
|
|
|
|
|
2016-02-26 21:34:07 +09:00
|
|
|
if (PEAR::isError($error = $this->put(base64_encode($pwd)))) {
|
2008-08-22 22:17:14 +09:00
|
|
|
return $error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 235: Authentication successful */
|
2016-02-26 21:34:07 +09:00
|
|
|
if (PEAR::isError($error = $this->parseResponse(235))) {
|
2008-08-22 22:17:14 +09:00
|
|
|
return $error;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Authenticates the user using the PLAIN method.
|
|
|
|
*
|
2016-02-26 21:34:07 +09:00
|
|
|
* @param string $uid The userid to authenticate as.
|
|
|
|
* @param string $pwd The password to authenticate with.
|
|
|
|
* @param string $authz The optional authorization proxy identifier.
|
2008-08-22 22:17:14 +09:00
|
|
|
*
|
|
|
|
* @return mixed Returns a PEAR_Error with an error message on any
|
|
|
|
* kind of failure, or true on success.
|
2016-02-26 21:34:07 +09:00
|
|
|
* @since 1.1.0
|
2008-08-22 22:17:14 +09:00
|
|
|
*/
|
2016-02-26 21:34:07 +09:00
|
|
|
protected function authPlain($uid, $pwd, $authz = '')
|
2008-08-22 22:17:14 +09:00
|
|
|
{
|
2016-02-26 21:34:07 +09:00
|
|
|
if (PEAR::isError($error = $this->put('AUTH', 'PLAIN'))) {
|
2008-08-22 22:17:14 +09:00
|
|
|
return $error;
|
|
|
|
}
|
|
|
|
/* 334: Continue authentication request */
|
2016-02-26 21:34:07 +09:00
|
|
|
if (PEAR::isError($error = $this->parseResponse(334))) {
|
2008-08-22 22:17:14 +09:00
|
|
|
/* 503: Error: already authenticated */
|
2016-02-26 21:34:07 +09:00
|
|
|
if ($this->code === 503) {
|
2008-08-22 22:17:14 +09:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return $error;
|
|
|
|
}
|
|
|
|
|
2016-02-26 21:34:07 +09:00
|
|
|
$auth_str = base64_encode($authz . chr(0) . $uid . chr(0) . $pwd);
|
2008-08-22 22:17:14 +09:00
|
|
|
|
2016-02-26 21:34:07 +09:00
|
|
|
if (PEAR::isError($error = $this->put($auth_str))) {
|
2008-08-22 22:17:14 +09:00
|
|
|
return $error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 235: Authentication successful */
|
2016-02-26 21:34:07 +09:00
|
|
|
if (PEAR::isError($error = $this->parseResponse(235))) {
|
2008-08-22 22:17:14 +09:00
|
|
|
return $error;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Send the HELO command.
|
|
|
|
*
|
2016-02-26 21:34:07 +09:00
|
|
|
* @param string $domain The domain name to say we are.
|
2008-08-22 22:17:14 +09:00
|
|
|
*
|
|
|
|
* @return mixed Returns a PEAR_Error with an error message on any
|
|
|
|
* kind of failure, or true on success.
|
2016-02-26 21:34:07 +09:00
|
|
|
* @since 1.0
|
2008-08-22 22:17:14 +09:00
|
|
|
*/
|
2016-02-26 21:34:07 +09:00
|
|
|
public function helo($domain)
|
2008-08-22 22:17:14 +09:00
|
|
|
{
|
2016-02-26 21:34:07 +09:00
|
|
|
if (PEAR::isError($error = $this->put('HELO', $domain))) {
|
2008-08-22 22:17:14 +09:00
|
|
|
return $error;
|
|
|
|
}
|
2016-02-26 21:34:07 +09:00
|
|
|
if (PEAR::isError($error = $this->parseResponse(250))) {
|
2008-08-22 22:17:14 +09:00
|
|
|
return $error;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the list of SMTP service extensions advertised by the server.
|
|
|
|
*
|
|
|
|
* @return array The list of SMTP service extensions.
|
|
|
|
* @since 1.3
|
|
|
|
*/
|
2016-02-26 21:34:07 +09:00
|
|
|
public function getServiceExtensions()
|
2008-08-22 22:17:14 +09:00
|
|
|
{
|
2016-02-26 21:34:07 +09:00
|
|
|
return $this->esmtp;
|
2008-08-22 22:17:14 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Send the MAIL FROM: command.
|
|
|
|
*
|
2016-02-26 21:34:07 +09:00
|
|
|
* @param string $sender The sender (reverse path) to set.
|
|
|
|
* @param string $params String containing additional MAIL parameters,
|
|
|
|
* such as the NOTIFY flags defined by RFC 1891
|
|
|
|
* or the VERP protocol.
|
2008-08-22 22:17:14 +09:00
|
|
|
*
|
2016-02-26 21:34:07 +09:00
|
|
|
* If $params is an array, only the 'verp' option
|
|
|
|
* is supported. If 'verp' is true, the XVERP
|
|
|
|
* parameter is appended to the MAIL command.
|
|
|
|
* If the 'verp' value is a string, the full
|
|
|
|
* XVERP=value parameter is appended.
|
2008-08-22 22:17:14 +09:00
|
|
|
*
|
|
|
|
* @return mixed Returns a PEAR_Error with an error message on any
|
|
|
|
* kind of failure, or true on success.
|
2016-02-26 21:34:07 +09:00
|
|
|
* @since 1.0
|
2008-08-22 22:17:14 +09:00
|
|
|
*/
|
2016-02-26 21:34:07 +09:00
|
|
|
public function mailFrom($sender, $params = null)
|
2008-08-22 22:17:14 +09:00
|
|
|
{
|
|
|
|
$args = "FROM:<$sender>";
|
|
|
|
|
|
|
|
/* Support the deprecated array form of $params. */
|
|
|
|
if (is_array($params) && isset($params['verp'])) {
|
|
|
|
if ($params['verp'] === true) {
|
|
|
|
$args .= ' XVERP';
|
|
|
|
} elseif (trim($params['verp'])) {
|
|
|
|
$args .= ' XVERP=' . $params['verp'];
|
|
|
|
}
|
2016-02-26 21:34:07 +09:00
|
|
|
} elseif (is_string($params) && !empty($params)) {
|
2008-08-22 22:17:14 +09:00
|
|
|
$args .= ' ' . $params;
|
|
|
|
}
|
|
|
|
|
2016-02-26 21:34:07 +09:00
|
|
|
if (PEAR::isError($error = $this->put('MAIL', $args))) {
|
2008-08-22 22:17:14 +09:00
|
|
|
return $error;
|
|
|
|
}
|
2016-02-26 21:34:07 +09:00
|
|
|
if (PEAR::isError($error = $this->parseResponse(250, $this->pipelining))) {
|
2008-08-22 22:17:14 +09:00
|
|
|
return $error;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Send the RCPT TO: command.
|
|
|
|
*
|
|
|
|
* @param string $recipient The recipient (forward path) to add.
|
|
|
|
* @param string $params String containing additional RCPT parameters,
|
|
|
|
* such as the NOTIFY flags defined by RFC 1891.
|
|
|
|
*
|
|
|
|
* @return mixed Returns a PEAR_Error with an error message on any
|
|
|
|
* kind of failure, or true on success.
|
|
|
|
*
|
2016-02-26 21:34:07 +09:00
|
|
|
* @since 1.0
|
2008-08-22 22:17:14 +09:00
|
|
|
*/
|
2016-02-26 21:34:07 +09:00
|
|
|
public function rcptTo($recipient, $params = null)
|
2008-08-22 22:17:14 +09:00
|
|
|
{
|
|
|
|
$args = "TO:<$recipient>";
|
|
|
|
if (is_string($params)) {
|
|
|
|
$args .= ' ' . $params;
|
|
|
|
}
|
|
|
|
|
2016-02-26 21:34:07 +09:00
|
|
|
if (PEAR::isError($error = $this->put('RCPT', $args))) {
|
2008-08-22 22:17:14 +09:00
|
|
|
return $error;
|
|
|
|
}
|
2016-02-26 21:34:07 +09:00
|
|
|
if (PEAR::isError($error = $this->parseResponse(array(250, 251), $this->pipelining))) {
|
2008-08-22 22:17:14 +09:00
|
|
|
return $error;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Quote the data so that it meets SMTP standards.
|
|
|
|
*
|
|
|
|
* This is provided as a separate public function to facilitate
|
|
|
|
* easier overloading for the cases where it is desirable to
|
|
|
|
* customize the quoting behavior.
|
|
|
|
*
|
2016-02-26 21:34:07 +09:00
|
|
|
* @param string &$data The message text to quote. The string must be passed
|
2008-08-22 22:17:14 +09:00
|
|
|
* by reference, and the text will be modified in place.
|
|
|
|
*
|
2016-02-26 21:34:07 +09:00
|
|
|
* @since 1.2
|
2008-08-22 22:17:14 +09:00
|
|
|
*/
|
2016-02-26 21:34:07 +09:00
|
|
|
public function quotedata(&$data)
|
2008-08-22 22:17:14 +09:00
|
|
|
{
|
|
|
|
/* Because a single leading period (.) signifies an end to the
|
2016-02-26 21:34:07 +09:00
|
|
|
* data, legitimate leading periods need to be "doubled" ('..'). */
|
|
|
|
$data = preg_replace('/^\./m', '..', $data);
|
|
|
|
|
|
|
|
/* Change Unix (\n) and Mac (\r) linefeeds into CRLF's (\r\n). */
|
|
|
|
$data = preg_replace('/(?:\r\n|\n|\r(?!\n))/', "\r\n", $data);
|
2008-08-22 22:17:14 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Send the DATA command.
|
|
|
|
*
|
2016-02-26 21:34:07 +09:00
|
|
|
* @param mixed $data The message data, either as a string or an open
|
extlibs updates: PEAR::Mail to 1.2.0, PEAR::Net_SMTP to 1.4.2 (need to go together as a pair)
PEAR::Mail updated to 1.2.0 from 1.1.4, fixes deprecation warnings on PHP 5.3, as well as:
1.2.0:
• QA release - stable.
• Updated minimum dependencies (Net_SMTP, PEAR, PHP)
• Doc Bug #15620 Licence change to BSD
• Bug #13659 Mail parse error in special condition
• Bug #16200 - Security hole allow to read/write Arbitrary File
_hasUnclosedQuotes() doesn't properly handle a double slash before an end quote (slusarz@curecanti.org, Bug #9137).
• Make sure Net_SMTP is defined when calling getSMTPObject() directly (slusarz@curecanti.org, Bug #13772).
• Add addServiceExtensionParameter() to the SMTP driver (slusarz@curecanti.org, Bug #13764).
• Add a method to obtain the Net_SMTP object from the SMTP driver (slusarz@curecanti.org, Bug #13766).
PEAR::Net_SMTP updated to 1.4.2 from 1.3.1, needed to support updated PEAR::Mail:
1.4.2:
• Fixing header string quoting in data(). (Bug #17199)
1.4.1:
• The auth() method now includes an optional $tls parameter that determines whether or not TLS should be attempted (if supported by the PHP runtime and the remote SMTP server). This parameter defaults to true. (Bug #16349)
• Header data can be specified separately from message body data by passing it as the optional second parameter to ``data()``. This is especially useful when an open file resource is being used to supply message data because it allows header fields (like *Subject:*) to be built dynamically at runtime. (Request #17012)
1.4.0:
• The data() method now accepts either a string or a file resource containing the message data. (Request #16962)
1.3.4:
• All Net_Socket write failures are now recognized. (Bug #16831)
1.3.3:
• Added getGreeting(), for retrieving the server's greeting string. (Request #16066) [needed for PEAR::Mail]
• We no longer attempt a TLS connection if we're already using a secure socket. (Bug #16254)
• You can now specify a debug output handler via setDebug(). (Request #16420)
1.3.2:
• TLS connection only gets started if no AUTH methods are sent. (Bug #14944)
2010-05-04 08:49:59 +09:00
|
|
|
* file resource.
|
|
|
|
* @param string $headers The message headers. If $headers is provided,
|
|
|
|
* $data is assumed to contain only body data.
|
2008-08-22 22:17:14 +09:00
|
|
|
*
|
|
|
|
* @return mixed Returns a PEAR_Error with an error message on any
|
|
|
|
* kind of failure, or true on success.
|
2016-02-26 21:34:07 +09:00
|
|
|
* @since 1.0
|
2008-08-22 22:17:14 +09:00
|
|
|
*/
|
2016-02-26 21:34:07 +09:00
|
|
|
public function data($data, $headers = null)
|
2008-08-22 22:17:14 +09:00
|
|
|
{
|
extlibs updates: PEAR::Mail to 1.2.0, PEAR::Net_SMTP to 1.4.2 (need to go together as a pair)
PEAR::Mail updated to 1.2.0 from 1.1.4, fixes deprecation warnings on PHP 5.3, as well as:
1.2.0:
• QA release - stable.
• Updated minimum dependencies (Net_SMTP, PEAR, PHP)
• Doc Bug #15620 Licence change to BSD
• Bug #13659 Mail parse error in special condition
• Bug #16200 - Security hole allow to read/write Arbitrary File
_hasUnclosedQuotes() doesn't properly handle a double slash before an end quote (slusarz@curecanti.org, Bug #9137).
• Make sure Net_SMTP is defined when calling getSMTPObject() directly (slusarz@curecanti.org, Bug #13772).
• Add addServiceExtensionParameter() to the SMTP driver (slusarz@curecanti.org, Bug #13764).
• Add a method to obtain the Net_SMTP object from the SMTP driver (slusarz@curecanti.org, Bug #13766).
PEAR::Net_SMTP updated to 1.4.2 from 1.3.1, needed to support updated PEAR::Mail:
1.4.2:
• Fixing header string quoting in data(). (Bug #17199)
1.4.1:
• The auth() method now includes an optional $tls parameter that determines whether or not TLS should be attempted (if supported by the PHP runtime and the remote SMTP server). This parameter defaults to true. (Bug #16349)
• Header data can be specified separately from message body data by passing it as the optional second parameter to ``data()``. This is especially useful when an open file resource is being used to supply message data because it allows header fields (like *Subject:*) to be built dynamically at runtime. (Request #17012)
1.4.0:
• The data() method now accepts either a string or a file resource containing the message data. (Request #16962)
1.3.4:
• All Net_Socket write failures are now recognized. (Bug #16831)
1.3.3:
• Added getGreeting(), for retrieving the server's greeting string. (Request #16066) [needed for PEAR::Mail]
• We no longer attempt a TLS connection if we're already using a secure socket. (Bug #16254)
• You can now specify a debug output handler via setDebug(). (Request #16420)
1.3.2:
• TLS connection only gets started if no AUTH methods are sent. (Bug #14944)
2010-05-04 08:49:59 +09:00
|
|
|
/* Verify that $data is a supported type. */
|
|
|
|
if (!is_string($data) && !is_resource($data)) {
|
|
|
|
return PEAR::raiseError('Expected a string or file resource');
|
|
|
|
}
|
|
|
|
|
2016-02-26 21:34:07 +09:00
|
|
|
/* Start by considering the size of the optional headers string. We
|
|
|
|
* also account for the addition 4 character "\r\n\r\n" separator
|
|
|
|
* sequence. */
|
|
|
|
$size = (is_null($headers)) ? 0 : strlen($headers) + 4;
|
extlibs updates: PEAR::Mail to 1.2.0, PEAR::Net_SMTP to 1.4.2 (need to go together as a pair)
PEAR::Mail updated to 1.2.0 from 1.1.4, fixes deprecation warnings on PHP 5.3, as well as:
1.2.0:
• QA release - stable.
• Updated minimum dependencies (Net_SMTP, PEAR, PHP)
• Doc Bug #15620 Licence change to BSD
• Bug #13659 Mail parse error in special condition
• Bug #16200 - Security hole allow to read/write Arbitrary File
_hasUnclosedQuotes() doesn't properly handle a double slash before an end quote (slusarz@curecanti.org, Bug #9137).
• Make sure Net_SMTP is defined when calling getSMTPObject() directly (slusarz@curecanti.org, Bug #13772).
• Add addServiceExtensionParameter() to the SMTP driver (slusarz@curecanti.org, Bug #13764).
• Add a method to obtain the Net_SMTP object from the SMTP driver (slusarz@curecanti.org, Bug #13766).
PEAR::Net_SMTP updated to 1.4.2 from 1.3.1, needed to support updated PEAR::Mail:
1.4.2:
• Fixing header string quoting in data(). (Bug #17199)
1.4.1:
• The auth() method now includes an optional $tls parameter that determines whether or not TLS should be attempted (if supported by the PHP runtime and the remote SMTP server). This parameter defaults to true. (Bug #16349)
• Header data can be specified separately from message body data by passing it as the optional second parameter to ``data()``. This is especially useful when an open file resource is being used to supply message data because it allows header fields (like *Subject:*) to be built dynamically at runtime. (Request #17012)
1.4.0:
• The data() method now accepts either a string or a file resource containing the message data. (Request #16962)
1.3.4:
• All Net_Socket write failures are now recognized. (Bug #16831)
1.3.3:
• Added getGreeting(), for retrieving the server's greeting string. (Request #16066) [needed for PEAR::Mail]
• We no longer attempt a TLS connection if we're already using a secure socket. (Bug #16254)
• You can now specify a debug output handler via setDebug(). (Request #16420)
1.3.2:
• TLS connection only gets started if no AUTH methods are sent. (Bug #14944)
2010-05-04 08:49:59 +09:00
|
|
|
|
2016-02-26 21:34:07 +09:00
|
|
|
if (is_resource($data)) {
|
|
|
|
$stat = fstat($data);
|
|
|
|
if ($stat === false) {
|
|
|
|
return PEAR::raiseError('Failed to get file size');
|
2008-08-22 22:17:14 +09:00
|
|
|
}
|
2016-02-26 21:34:07 +09:00
|
|
|
$size += $stat['size'];
|
|
|
|
} else {
|
|
|
|
$size += strlen($data);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* RFC 1870, section 3, subsection 3 states "a value of zero indicates
|
|
|
|
* that no fixed maximum message size is in force". Furthermore, it
|
|
|
|
* says that if "the parameter is omitted no information is conveyed
|
|
|
|
* about the server's fixed maximum message size". */
|
|
|
|
$limit = (isset($this->esmtp['SIZE'])) ? $this->esmtp['SIZE'] : 0;
|
|
|
|
if ($limit > 0 && $size >= $limit) {
|
|
|
|
$this->disconnect();
|
|
|
|
return PEAR::raiseError('Message size exceeds server limit');
|
2008-08-22 22:17:14 +09:00
|
|
|
}
|
|
|
|
|
extlibs updates: PEAR::Mail to 1.2.0, PEAR::Net_SMTP to 1.4.2 (need to go together as a pair)
PEAR::Mail updated to 1.2.0 from 1.1.4, fixes deprecation warnings on PHP 5.3, as well as:
1.2.0:
• QA release - stable.
• Updated minimum dependencies (Net_SMTP, PEAR, PHP)
• Doc Bug #15620 Licence change to BSD
• Bug #13659 Mail parse error in special condition
• Bug #16200 - Security hole allow to read/write Arbitrary File
_hasUnclosedQuotes() doesn't properly handle a double slash before an end quote (slusarz@curecanti.org, Bug #9137).
• Make sure Net_SMTP is defined when calling getSMTPObject() directly (slusarz@curecanti.org, Bug #13772).
• Add addServiceExtensionParameter() to the SMTP driver (slusarz@curecanti.org, Bug #13764).
• Add a method to obtain the Net_SMTP object from the SMTP driver (slusarz@curecanti.org, Bug #13766).
PEAR::Net_SMTP updated to 1.4.2 from 1.3.1, needed to support updated PEAR::Mail:
1.4.2:
• Fixing header string quoting in data(). (Bug #17199)
1.4.1:
• The auth() method now includes an optional $tls parameter that determines whether or not TLS should be attempted (if supported by the PHP runtime and the remote SMTP server). This parameter defaults to true. (Bug #16349)
• Header data can be specified separately from message body data by passing it as the optional second parameter to ``data()``. This is especially useful when an open file resource is being used to supply message data because it allows header fields (like *Subject:*) to be built dynamically at runtime. (Request #17012)
1.4.0:
• The data() method now accepts either a string or a file resource containing the message data. (Request #16962)
1.3.4:
• All Net_Socket write failures are now recognized. (Bug #16831)
1.3.3:
• Added getGreeting(), for retrieving the server's greeting string. (Request #16066) [needed for PEAR::Mail]
• We no longer attempt a TLS connection if we're already using a secure socket. (Bug #16254)
• You can now specify a debug output handler via setDebug(). (Request #16420)
1.3.2:
• TLS connection only gets started if no AUTH methods are sent. (Bug #14944)
2010-05-04 08:49:59 +09:00
|
|
|
/* Initiate the DATA command. */
|
2016-02-26 21:34:07 +09:00
|
|
|
if (PEAR::isError($error = $this->put('DATA'))) {
|
2008-08-22 22:17:14 +09:00
|
|
|
return $error;
|
|
|
|
}
|
2016-02-26 21:34:07 +09:00
|
|
|
if (PEAR::isError($error = $this->parseResponse(354))) {
|
2008-08-22 22:17:14 +09:00
|
|
|
return $error;
|
|
|
|
}
|
|
|
|
|
extlibs updates: PEAR::Mail to 1.2.0, PEAR::Net_SMTP to 1.4.2 (need to go together as a pair)
PEAR::Mail updated to 1.2.0 from 1.1.4, fixes deprecation warnings on PHP 5.3, as well as:
1.2.0:
• QA release - stable.
• Updated minimum dependencies (Net_SMTP, PEAR, PHP)
• Doc Bug #15620 Licence change to BSD
• Bug #13659 Mail parse error in special condition
• Bug #16200 - Security hole allow to read/write Arbitrary File
_hasUnclosedQuotes() doesn't properly handle a double slash before an end quote (slusarz@curecanti.org, Bug #9137).
• Make sure Net_SMTP is defined when calling getSMTPObject() directly (slusarz@curecanti.org, Bug #13772).
• Add addServiceExtensionParameter() to the SMTP driver (slusarz@curecanti.org, Bug #13764).
• Add a method to obtain the Net_SMTP object from the SMTP driver (slusarz@curecanti.org, Bug #13766).
PEAR::Net_SMTP updated to 1.4.2 from 1.3.1, needed to support updated PEAR::Mail:
1.4.2:
• Fixing header string quoting in data(). (Bug #17199)
1.4.1:
• The auth() method now includes an optional $tls parameter that determines whether or not TLS should be attempted (if supported by the PHP runtime and the remote SMTP server). This parameter defaults to true. (Bug #16349)
• Header data can be specified separately from message body data by passing it as the optional second parameter to ``data()``. This is especially useful when an open file resource is being used to supply message data because it allows header fields (like *Subject:*) to be built dynamically at runtime. (Request #17012)
1.4.0:
• The data() method now accepts either a string or a file resource containing the message data. (Request #16962)
1.3.4:
• All Net_Socket write failures are now recognized. (Bug #16831)
1.3.3:
• Added getGreeting(), for retrieving the server's greeting string. (Request #16066) [needed for PEAR::Mail]
• We no longer attempt a TLS connection if we're already using a secure socket. (Bug #16254)
• You can now specify a debug output handler via setDebug(). (Request #16420)
1.3.2:
• TLS connection only gets started if no AUTH methods are sent. (Bug #14944)
2010-05-04 08:49:59 +09:00
|
|
|
/* If we have a separate headers string, send it first. */
|
|
|
|
if (!is_null($headers)) {
|
|
|
|
$this->quotedata($headers);
|
2016-02-26 21:34:07 +09:00
|
|
|
if (PEAR::isError($result = $this->send($headers . "\r\n\r\n"))) {
|
extlibs updates: PEAR::Mail to 1.2.0, PEAR::Net_SMTP to 1.4.2 (need to go together as a pair)
PEAR::Mail updated to 1.2.0 from 1.1.4, fixes deprecation warnings on PHP 5.3, as well as:
1.2.0:
• QA release - stable.
• Updated minimum dependencies (Net_SMTP, PEAR, PHP)
• Doc Bug #15620 Licence change to BSD
• Bug #13659 Mail parse error in special condition
• Bug #16200 - Security hole allow to read/write Arbitrary File
_hasUnclosedQuotes() doesn't properly handle a double slash before an end quote (slusarz@curecanti.org, Bug #9137).
• Make sure Net_SMTP is defined when calling getSMTPObject() directly (slusarz@curecanti.org, Bug #13772).
• Add addServiceExtensionParameter() to the SMTP driver (slusarz@curecanti.org, Bug #13764).
• Add a method to obtain the Net_SMTP object from the SMTP driver (slusarz@curecanti.org, Bug #13766).
PEAR::Net_SMTP updated to 1.4.2 from 1.3.1, needed to support updated PEAR::Mail:
1.4.2:
• Fixing header string quoting in data(). (Bug #17199)
1.4.1:
• The auth() method now includes an optional $tls parameter that determines whether or not TLS should be attempted (if supported by the PHP runtime and the remote SMTP server). This parameter defaults to true. (Bug #16349)
• Header data can be specified separately from message body data by passing it as the optional second parameter to ``data()``. This is especially useful when an open file resource is being used to supply message data because it allows header fields (like *Subject:*) to be built dynamically at runtime. (Request #17012)
1.4.0:
• The data() method now accepts either a string or a file resource containing the message data. (Request #16962)
1.3.4:
• All Net_Socket write failures are now recognized. (Bug #16831)
1.3.3:
• Added getGreeting(), for retrieving the server's greeting string. (Request #16066) [needed for PEAR::Mail]
• We no longer attempt a TLS connection if we're already using a secure socket. (Bug #16254)
• You can now specify a debug output handler via setDebug(). (Request #16420)
1.3.2:
• TLS connection only gets started if no AUTH methods are sent. (Bug #14944)
2010-05-04 08:49:59 +09:00
|
|
|
return $result;
|
|
|
|
}
|
2008-08-22 22:17:14 +09:00
|
|
|
}
|
extlibs updates: PEAR::Mail to 1.2.0, PEAR::Net_SMTP to 1.4.2 (need to go together as a pair)
PEAR::Mail updated to 1.2.0 from 1.1.4, fixes deprecation warnings on PHP 5.3, as well as:
1.2.0:
• QA release - stable.
• Updated minimum dependencies (Net_SMTP, PEAR, PHP)
• Doc Bug #15620 Licence change to BSD
• Bug #13659 Mail parse error in special condition
• Bug #16200 - Security hole allow to read/write Arbitrary File
_hasUnclosedQuotes() doesn't properly handle a double slash before an end quote (slusarz@curecanti.org, Bug #9137).
• Make sure Net_SMTP is defined when calling getSMTPObject() directly (slusarz@curecanti.org, Bug #13772).
• Add addServiceExtensionParameter() to the SMTP driver (slusarz@curecanti.org, Bug #13764).
• Add a method to obtain the Net_SMTP object from the SMTP driver (slusarz@curecanti.org, Bug #13766).
PEAR::Net_SMTP updated to 1.4.2 from 1.3.1, needed to support updated PEAR::Mail:
1.4.2:
• Fixing header string quoting in data(). (Bug #17199)
1.4.1:
• The auth() method now includes an optional $tls parameter that determines whether or not TLS should be attempted (if supported by the PHP runtime and the remote SMTP server). This parameter defaults to true. (Bug #16349)
• Header data can be specified separately from message body data by passing it as the optional second parameter to ``data()``. This is especially useful when an open file resource is being used to supply message data because it allows header fields (like *Subject:*) to be built dynamically at runtime. (Request #17012)
1.4.0:
• The data() method now accepts either a string or a file resource containing the message data. (Request #16962)
1.3.4:
• All Net_Socket write failures are now recognized. (Bug #16831)
1.3.3:
• Added getGreeting(), for retrieving the server's greeting string. (Request #16066) [needed for PEAR::Mail]
• We no longer attempt a TLS connection if we're already using a secure socket. (Bug #16254)
• You can now specify a debug output handler via setDebug(). (Request #16420)
1.3.2:
• TLS connection only gets started if no AUTH methods are sent. (Bug #14944)
2010-05-04 08:49:59 +09:00
|
|
|
|
|
|
|
/* Now we can send the message body data. */
|
|
|
|
if (is_resource($data)) {
|
|
|
|
/* Stream the contents of the file resource out over our socket
|
|
|
|
* connection, line by line. Each line must be run through the
|
|
|
|
* quoting routine. */
|
2016-02-26 21:34:07 +09:00
|
|
|
while (strlen($line = fread($data, 8192)) > 0) {
|
|
|
|
/* If the last character is an newline, we need to grab the
|
|
|
|
* next character to check to see if it is a period. */
|
|
|
|
while (!feof($data)) {
|
|
|
|
$char = fread($data, 1);
|
|
|
|
$line .= $char;
|
|
|
|
if ($char != "\n") {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
extlibs updates: PEAR::Mail to 1.2.0, PEAR::Net_SMTP to 1.4.2 (need to go together as a pair)
PEAR::Mail updated to 1.2.0 from 1.1.4, fixes deprecation warnings on PHP 5.3, as well as:
1.2.0:
• QA release - stable.
• Updated minimum dependencies (Net_SMTP, PEAR, PHP)
• Doc Bug #15620 Licence change to BSD
• Bug #13659 Mail parse error in special condition
• Bug #16200 - Security hole allow to read/write Arbitrary File
_hasUnclosedQuotes() doesn't properly handle a double slash before an end quote (slusarz@curecanti.org, Bug #9137).
• Make sure Net_SMTP is defined when calling getSMTPObject() directly (slusarz@curecanti.org, Bug #13772).
• Add addServiceExtensionParameter() to the SMTP driver (slusarz@curecanti.org, Bug #13764).
• Add a method to obtain the Net_SMTP object from the SMTP driver (slusarz@curecanti.org, Bug #13766).
PEAR::Net_SMTP updated to 1.4.2 from 1.3.1, needed to support updated PEAR::Mail:
1.4.2:
• Fixing header string quoting in data(). (Bug #17199)
1.4.1:
• The auth() method now includes an optional $tls parameter that determines whether or not TLS should be attempted (if supported by the PHP runtime and the remote SMTP server). This parameter defaults to true. (Bug #16349)
• Header data can be specified separately from message body data by passing it as the optional second parameter to ``data()``. This is especially useful when an open file resource is being used to supply message data because it allows header fields (like *Subject:*) to be built dynamically at runtime. (Request #17012)
1.4.0:
• The data() method now accepts either a string or a file resource containing the message data. (Request #16962)
1.3.4:
• All Net_Socket write failures are now recognized. (Bug #16831)
1.3.3:
• Added getGreeting(), for retrieving the server's greeting string. (Request #16066) [needed for PEAR::Mail]
• We no longer attempt a TLS connection if we're already using a secure socket. (Bug #16254)
• You can now specify a debug output handler via setDebug(). (Request #16420)
1.3.2:
• TLS connection only gets started if no AUTH methods are sent. (Bug #14944)
2010-05-04 08:49:59 +09:00
|
|
|
$this->quotedata($line);
|
2016-02-26 21:34:07 +09:00
|
|
|
if (PEAR::isError($result = $this->send($line))) {
|
extlibs updates: PEAR::Mail to 1.2.0, PEAR::Net_SMTP to 1.4.2 (need to go together as a pair)
PEAR::Mail updated to 1.2.0 from 1.1.4, fixes deprecation warnings on PHP 5.3, as well as:
1.2.0:
• QA release - stable.
• Updated minimum dependencies (Net_SMTP, PEAR, PHP)
• Doc Bug #15620 Licence change to BSD
• Bug #13659 Mail parse error in special condition
• Bug #16200 - Security hole allow to read/write Arbitrary File
_hasUnclosedQuotes() doesn't properly handle a double slash before an end quote (slusarz@curecanti.org, Bug #9137).
• Make sure Net_SMTP is defined when calling getSMTPObject() directly (slusarz@curecanti.org, Bug #13772).
• Add addServiceExtensionParameter() to the SMTP driver (slusarz@curecanti.org, Bug #13764).
• Add a method to obtain the Net_SMTP object from the SMTP driver (slusarz@curecanti.org, Bug #13766).
PEAR::Net_SMTP updated to 1.4.2 from 1.3.1, needed to support updated PEAR::Mail:
1.4.2:
• Fixing header string quoting in data(). (Bug #17199)
1.4.1:
• The auth() method now includes an optional $tls parameter that determines whether or not TLS should be attempted (if supported by the PHP runtime and the remote SMTP server). This parameter defaults to true. (Bug #16349)
• Header data can be specified separately from message body data by passing it as the optional second parameter to ``data()``. This is especially useful when an open file resource is being used to supply message data because it allows header fields (like *Subject:*) to be built dynamically at runtime. (Request #17012)
1.4.0:
• The data() method now accepts either a string or a file resource containing the message data. (Request #16962)
1.3.4:
• All Net_Socket write failures are now recognized. (Bug #16831)
1.3.3:
• Added getGreeting(), for retrieving the server's greeting string. (Request #16066) [needed for PEAR::Mail]
• We no longer attempt a TLS connection if we're already using a secure socket. (Bug #16254)
• You can now specify a debug output handler via setDebug(). (Request #16420)
1.3.2:
• TLS connection only gets started if no AUTH methods are sent. (Bug #14944)
2010-05-04 08:49:59 +09:00
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-26 21:34:07 +09:00
|
|
|
$last = $line;
|
extlibs updates: PEAR::Mail to 1.2.0, PEAR::Net_SMTP to 1.4.2 (need to go together as a pair)
PEAR::Mail updated to 1.2.0 from 1.1.4, fixes deprecation warnings on PHP 5.3, as well as:
1.2.0:
• QA release - stable.
• Updated minimum dependencies (Net_SMTP, PEAR, PHP)
• Doc Bug #15620 Licence change to BSD
• Bug #13659 Mail parse error in special condition
• Bug #16200 - Security hole allow to read/write Arbitrary File
_hasUnclosedQuotes() doesn't properly handle a double slash before an end quote (slusarz@curecanti.org, Bug #9137).
• Make sure Net_SMTP is defined when calling getSMTPObject() directly (slusarz@curecanti.org, Bug #13772).
• Add addServiceExtensionParameter() to the SMTP driver (slusarz@curecanti.org, Bug #13764).
• Add a method to obtain the Net_SMTP object from the SMTP driver (slusarz@curecanti.org, Bug #13766).
PEAR::Net_SMTP updated to 1.4.2 from 1.3.1, needed to support updated PEAR::Mail:
1.4.2:
• Fixing header string quoting in data(). (Bug #17199)
1.4.1:
• The auth() method now includes an optional $tls parameter that determines whether or not TLS should be attempted (if supported by the PHP runtime and the remote SMTP server). This parameter defaults to true. (Bug #16349)
• Header data can be specified separately from message body data by passing it as the optional second parameter to ``data()``. This is especially useful when an open file resource is being used to supply message data because it allows header fields (like *Subject:*) to be built dynamically at runtime. (Request #17012)
1.4.0:
• The data() method now accepts either a string or a file resource containing the message data. (Request #16962)
1.3.4:
• All Net_Socket write failures are now recognized. (Bug #16831)
1.3.3:
• Added getGreeting(), for retrieving the server's greeting string. (Request #16066) [needed for PEAR::Mail]
• We no longer attempt a TLS connection if we're already using a secure socket. (Bug #16254)
• You can now specify a debug output handler via setDebug(). (Request #16420)
1.3.2:
• TLS connection only gets started if no AUTH methods are sent. (Bug #14944)
2010-05-04 08:49:59 +09:00
|
|
|
} else {
|
2016-02-26 21:34:07 +09:00
|
|
|
/*
|
|
|
|
* Break up the data by sending one chunk (up to 512k) at a time.
|
|
|
|
* This approach reduces our peak memory usage.
|
|
|
|
*/
|
|
|
|
for ($offset = 0; $offset < $size;) {
|
|
|
|
$end = $offset + 512000;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Ensure we don't read beyond our data size or span multiple
|
|
|
|
* lines. quotedata() can't properly handle character data
|
|
|
|
* that's split across two line break boundaries.
|
|
|
|
*/
|
|
|
|
if ($end >= $size) {
|
|
|
|
$end = $size;
|
|
|
|
} else {
|
|
|
|
for (; $end < $size; $end++) {
|
|
|
|
if ($data[$end] != "\n") {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Extract our chunk and run it through the quoting routine. */
|
|
|
|
$chunk = substr($data, $offset, $end - $offset);
|
|
|
|
$this->quotedata($chunk);
|
|
|
|
|
|
|
|
/* If we run into a problem along the way, abort. */
|
|
|
|
if (PEAR::isError($result = $this->send($chunk))) {
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Advance the offset to the end of this chunk. */
|
|
|
|
$offset = $end;
|
extlibs updates: PEAR::Mail to 1.2.0, PEAR::Net_SMTP to 1.4.2 (need to go together as a pair)
PEAR::Mail updated to 1.2.0 from 1.1.4, fixes deprecation warnings on PHP 5.3, as well as:
1.2.0:
• QA release - stable.
• Updated minimum dependencies (Net_SMTP, PEAR, PHP)
• Doc Bug #15620 Licence change to BSD
• Bug #13659 Mail parse error in special condition
• Bug #16200 - Security hole allow to read/write Arbitrary File
_hasUnclosedQuotes() doesn't properly handle a double slash before an end quote (slusarz@curecanti.org, Bug #9137).
• Make sure Net_SMTP is defined when calling getSMTPObject() directly (slusarz@curecanti.org, Bug #13772).
• Add addServiceExtensionParameter() to the SMTP driver (slusarz@curecanti.org, Bug #13764).
• Add a method to obtain the Net_SMTP object from the SMTP driver (slusarz@curecanti.org, Bug #13766).
PEAR::Net_SMTP updated to 1.4.2 from 1.3.1, needed to support updated PEAR::Mail:
1.4.2:
• Fixing header string quoting in data(). (Bug #17199)
1.4.1:
• The auth() method now includes an optional $tls parameter that determines whether or not TLS should be attempted (if supported by the PHP runtime and the remote SMTP server). This parameter defaults to true. (Bug #16349)
• Header data can be specified separately from message body data by passing it as the optional second parameter to ``data()``. This is especially useful when an open file resource is being used to supply message data because it allows header fields (like *Subject:*) to be built dynamically at runtime. (Request #17012)
1.4.0:
• The data() method now accepts either a string or a file resource containing the message data. (Request #16962)
1.3.4:
• All Net_Socket write failures are now recognized. (Bug #16831)
1.3.3:
• Added getGreeting(), for retrieving the server's greeting string. (Request #16066) [needed for PEAR::Mail]
• We no longer attempt a TLS connection if we're already using a secure socket. (Bug #16254)
• You can now specify a debug output handler via setDebug(). (Request #16420)
1.3.2:
• TLS connection only gets started if no AUTH methods are sent. (Bug #14944)
2010-05-04 08:49:59 +09:00
|
|
|
}
|
2016-02-26 21:34:07 +09:00
|
|
|
|
|
|
|
$last = $chunk;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Don't add another CRLF sequence if it's already in the data */
|
|
|
|
$terminator = (substr($last, -2) == "\r\n" ? '' : "\r\n") . ".\r\n";
|
|
|
|
|
|
|
|
/* Finally, send the DATA terminator sequence. */
|
|
|
|
if (PEAR::isError($result = $this->send($terminator))) {
|
|
|
|
return $result;
|
extlibs updates: PEAR::Mail to 1.2.0, PEAR::Net_SMTP to 1.4.2 (need to go together as a pair)
PEAR::Mail updated to 1.2.0 from 1.1.4, fixes deprecation warnings on PHP 5.3, as well as:
1.2.0:
• QA release - stable.
• Updated minimum dependencies (Net_SMTP, PEAR, PHP)
• Doc Bug #15620 Licence change to BSD
• Bug #13659 Mail parse error in special condition
• Bug #16200 - Security hole allow to read/write Arbitrary File
_hasUnclosedQuotes() doesn't properly handle a double slash before an end quote (slusarz@curecanti.org, Bug #9137).
• Make sure Net_SMTP is defined when calling getSMTPObject() directly (slusarz@curecanti.org, Bug #13772).
• Add addServiceExtensionParameter() to the SMTP driver (slusarz@curecanti.org, Bug #13764).
• Add a method to obtain the Net_SMTP object from the SMTP driver (slusarz@curecanti.org, Bug #13766).
PEAR::Net_SMTP updated to 1.4.2 from 1.3.1, needed to support updated PEAR::Mail:
1.4.2:
• Fixing header string quoting in data(). (Bug #17199)
1.4.1:
• The auth() method now includes an optional $tls parameter that determines whether or not TLS should be attempted (if supported by the PHP runtime and the remote SMTP server). This parameter defaults to true. (Bug #16349)
• Header data can be specified separately from message body data by passing it as the optional second parameter to ``data()``. This is especially useful when an open file resource is being used to supply message data because it allows header fields (like *Subject:*) to be built dynamically at runtime. (Request #17012)
1.4.0:
• The data() method now accepts either a string or a file resource containing the message data. (Request #16962)
1.3.4:
• All Net_Socket write failures are now recognized. (Bug #16831)
1.3.3:
• Added getGreeting(), for retrieving the server's greeting string. (Request #16066) [needed for PEAR::Mail]
• We no longer attempt a TLS connection if we're already using a secure socket. (Bug #16254)
• You can now specify a debug output handler via setDebug(). (Request #16420)
1.3.2:
• TLS connection only gets started if no AUTH methods are sent. (Bug #14944)
2010-05-04 08:49:59 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Verify that the data was successfully received by the server. */
|
2016-02-26 21:34:07 +09:00
|
|
|
if (PEAR::isError($error = $this->parseResponse(250, $this->pipelining))) {
|
2008-08-22 22:17:14 +09:00
|
|
|
return $error;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Send the SEND FROM: command.
|
|
|
|
*
|
2016-02-26 21:34:07 +09:00
|
|
|
* @param string $path The reverse path to send.
|
2008-08-22 22:17:14 +09:00
|
|
|
*
|
|
|
|
* @return mixed Returns a PEAR_Error with an error message on any
|
|
|
|
* kind of failure, or true on success.
|
2016-02-26 21:34:07 +09:00
|
|
|
* @since 1.2.6
|
2008-08-22 22:17:14 +09:00
|
|
|
*/
|
2016-02-26 21:34:07 +09:00
|
|
|
public function sendFrom($path)
|
2008-08-22 22:17:14 +09:00
|
|
|
{
|
2016-02-26 21:34:07 +09:00
|
|
|
if (PEAR::isError($error = $this->put('SEND', "FROM:<$path>"))) {
|
2008-08-22 22:17:14 +09:00
|
|
|
return $error;
|
|
|
|
}
|
2016-02-26 21:34:07 +09:00
|
|
|
if (PEAR::isError($error = $this->parseResponse(250, $this->pipelining))) {
|
2008-08-22 22:17:14 +09:00
|
|
|
return $error;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Send the SOML FROM: command.
|
|
|
|
*
|
2016-02-26 21:34:07 +09:00
|
|
|
* @param string $path The reverse path to send.
|
2008-08-22 22:17:14 +09:00
|
|
|
*
|
|
|
|
* @return mixed Returns a PEAR_Error with an error message on any
|
|
|
|
* kind of failure, or true on success.
|
2016-02-26 21:34:07 +09:00
|
|
|
* @since 1.2.6
|
2008-08-22 22:17:14 +09:00
|
|
|
*/
|
2016-02-26 21:34:07 +09:00
|
|
|
public function somlFrom($path)
|
2008-08-22 22:17:14 +09:00
|
|
|
{
|
2016-02-26 21:34:07 +09:00
|
|
|
if (PEAR::isError($error = $this->put('SOML', "FROM:<$path>"))) {
|
2008-08-22 22:17:14 +09:00
|
|
|
return $error;
|
|
|
|
}
|
2016-02-26 21:34:07 +09:00
|
|
|
if (PEAR::isError($error = $this->parseResponse(250, $this->pipelining))) {
|
2008-08-22 22:17:14 +09:00
|
|
|
return $error;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Send the SAML FROM: command.
|
|
|
|
*
|
2016-02-26 21:34:07 +09:00
|
|
|
* @param string $path The reverse path to send.
|
2008-08-22 22:17:14 +09:00
|
|
|
*
|
|
|
|
* @return mixed Returns a PEAR_Error with an error message on any
|
|
|
|
* kind of failure, or true on success.
|
2016-02-26 21:34:07 +09:00
|
|
|
* @since 1.2.6
|
2008-08-22 22:17:14 +09:00
|
|
|
*/
|
2016-02-26 21:34:07 +09:00
|
|
|
public function samlFrom($path)
|
2008-08-22 22:17:14 +09:00
|
|
|
{
|
2016-02-26 21:34:07 +09:00
|
|
|
if (PEAR::isError($error = $this->put('SAML', "FROM:<$path>"))) {
|
2008-08-22 22:17:14 +09:00
|
|
|
return $error;
|
|
|
|
}
|
2016-02-26 21:34:07 +09:00
|
|
|
if (PEAR::isError($error = $this->parseResponse(250, $this->pipelining))) {
|
2008-08-22 22:17:14 +09:00
|
|
|
return $error;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Send the RSET command.
|
|
|
|
*
|
|
|
|
* @return mixed Returns a PEAR_Error with an error message on any
|
|
|
|
* kind of failure, or true on success.
|
|
|
|
* @since 1.0
|
|
|
|
*/
|
2016-02-26 21:34:07 +09:00
|
|
|
public function rset()
|
2008-08-22 22:17:14 +09:00
|
|
|
{
|
2016-02-26 21:34:07 +09:00
|
|
|
if (PEAR::isError($error = $this->put('RSET'))) {
|
2008-08-22 22:17:14 +09:00
|
|
|
return $error;
|
|
|
|
}
|
2016-02-26 21:34:07 +09:00
|
|
|
if (PEAR::isError($error = $this->parseResponse(250, $this->pipelining))) {
|
2008-08-22 22:17:14 +09:00
|
|
|
return $error;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Send the VRFY command.
|
|
|
|
*
|
2016-02-26 21:34:07 +09:00
|
|
|
* @param string $string The string to verify
|
2008-08-22 22:17:14 +09:00
|
|
|
*
|
|
|
|
* @return mixed Returns a PEAR_Error with an error message on any
|
|
|
|
* kind of failure, or true on success.
|
2016-02-26 21:34:07 +09:00
|
|
|
* @since 1.0
|
2008-08-22 22:17:14 +09:00
|
|
|
*/
|
2016-02-26 21:34:07 +09:00
|
|
|
public function vrfy($string)
|
2008-08-22 22:17:14 +09:00
|
|
|
{
|
|
|
|
/* Note: 251 is also a valid response code */
|
2016-02-26 21:34:07 +09:00
|
|
|
if (PEAR::isError($error = $this->put('VRFY', $string))) {
|
2008-08-22 22:17:14 +09:00
|
|
|
return $error;
|
|
|
|
}
|
2016-02-26 21:34:07 +09:00
|
|
|
if (PEAR::isError($error = $this->parseResponse(array(250, 252)))) {
|
2008-08-22 22:17:14 +09:00
|
|
|
return $error;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Send the NOOP command.
|
|
|
|
*
|
|
|
|
* @return mixed Returns a PEAR_Error with an error message on any
|
|
|
|
* kind of failure, or true on success.
|
2016-02-26 21:34:07 +09:00
|
|
|
* @since 1.0
|
2008-08-22 22:17:14 +09:00
|
|
|
*/
|
2016-02-26 21:34:07 +09:00
|
|
|
public function noop()
|
2008-08-22 22:17:14 +09:00
|
|
|
{
|
2016-02-26 21:34:07 +09:00
|
|
|
if (PEAR::isError($error = $this->put('NOOP'))) {
|
2008-08-22 22:17:14 +09:00
|
|
|
return $error;
|
|
|
|
}
|
2016-02-26 21:34:07 +09:00
|
|
|
if (PEAR::isError($error = $this->parseResponse(250))) {
|
2008-08-22 22:17:14 +09:00
|
|
|
return $error;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Backwards-compatibility method. identifySender()'s functionality is
|
|
|
|
* now handled internally.
|
|
|
|
*
|
2016-02-26 21:34:07 +09:00
|
|
|
* @return boolean This method always return true.
|
2008-08-22 22:17:14 +09:00
|
|
|
*
|
2016-02-26 21:34:07 +09:00
|
|
|
* @since 1.0
|
2008-08-22 22:17:14 +09:00
|
|
|
*/
|
2016-02-26 21:34:07 +09:00
|
|
|
public function identifySender()
|
2008-08-22 22:17:14 +09:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|