/**
* SMTP implementation of the PEAR Mail interface. Requires the Net_SMTP class.
*
- * PHP versions 4 and 5
+ * PHP version 5
*
* LICENSE:
*
* @author Chuck Hagenbuch <chuck@horde.org>
* @copyright 2010 Chuck Hagenbuch
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: smtp.php 294747 2010-02-08 08:18:33Z clockwerx $
+ * @version CVS: $Id$
* @link http://pear.php.net/package/Mail/
*/
* SMTP implementation of the PEAR Mail interface. Requires the Net_SMTP class.
* @access public
* @package Mail
- * @version $Revision: 294747 $
+ * @version $Revision$
*/
class Mail_smtp extends Mail {
* @var bool
*/
var $pipelining;
+
+ var $socket_options = array();
/**
* Constructor.
*
* @param array Hash containing any parameters different from the
* defaults.
- * @access public
*/
- function Mail_smtp($params)
+ public function __construct($params)
{
if (isset($params['host'])) $this->host = $params['host'];
if (isset($params['port'])) $this->port = $params['port'];
if (isset($params['debug'])) $this->debug = (bool)$params['debug'];
if (isset($params['persist'])) $this->persist = (bool)$params['persist'];
if (isset($params['pipelining'])) $this->pipelining = (bool)$params['pipelining'];
-
+ if (isset($params['socket_options'])) $this->socket_options = $params['socket_options'];
// Deprecated options
if (isset($params['verp'])) {
$this->addServiceExtensionParameter('XVERP', is_bool($params['verp']) ? null : $params['verp']);
}
-
- register_shutdown_function(array(&$this, '_Mail_smtp'));
}
/**
* Destructor implementation to ensure that we disconnect from any
* potentially-alive persistent SMTP connections.
*/
- function _Mail_smtp()
+ public function __destruct()
{
$this->disconnect();
}
* @return mixed Returns true on success, or a PEAR_Error
* containing a descriptive error message on
* failure.
- * @access public
*/
- function send($recipients, $headers, $body)
+ public function send($recipients, $headers, $body)
{
/* If we don't already have an SMTP object, create one. */
- $result = &$this->getSMTPObject();
+ $result = $this->getSMTPObject();
if (PEAR::isError($result)) {
return $result;
}
}
/* Send the message's headers and the body as SMTP data. */
- $res = $this->_smtp->data($textHeaders . "\r\n\r\n" . $body);
+ $res = $this->_smtp->data($body, $textHeaders);
list(,$args) = $this->_smtp->getResponse();
if (preg_match("/Ok: queued as (.*)/", $args, $queued)) {
* failure.
*
* @since 1.2.0
- * @access public
*/
- function &getSMTPObject()
+ public function getSMTPObject()
{
if (is_object($this->_smtp) !== false) {
return $this->_smtp;
}
include_once 'Net/SMTP.php';
- $this->_smtp = &new Net_SMTP($this->host,
+ $this->_smtp = new Net_SMTP($this->host,
$this->port,
- $this->localhost);
+ $this->localhost,
+ $this->pipelining,
+ 0,
+ $this->socket_options);
/* If we still don't have an SMTP object at this point, fail. */
if (is_object($this->_smtp) === false) {
* @param string Any value the keyword needs.
*
* @since 1.2.0
- * @access public
*/
- function addServiceExtensionParameter($keyword, $value = null)
+ public function addServiceExtensionParameter($keyword, $value = null)
{
$this->_extparams[$keyword] = $value;
}
* @return boolean True if the SMTP connection no longer exists.
*
* @since 1.1.9
- * @access public
*/
- function disconnect()
+ public function disconnect()
{
/* If we have an SMTP object, disconnect and destroy it. */
if (is_object($this->_smtp) && $this->_smtp->disconnect()) {
* @return string A string describing the current SMTP error.
*
* @since 1.1.7
- * @access private
*/
- function _error($text, &$error)
+ protected function _error($text, $error)
{
/* Split the SMTP response into a code and a response string. */
list($code, $response) = $this->_smtp->getResponse();