cvs: pear /Mail package.xml /Mail/Mail smtp.php
[email protected] ("Chuck Hagenbuch")
| Newsgroups | php.pear.cvs |
|---|---|
| Message-ID | <cvschagenbu1209073420@cvsserver> |
chagenbu Thu Apr 24 21:43:40 2008 UTC
Modified files:
/pear/Mail package.xml
/pear/Mail/Mail smtp.php
Log:
- Add addServiceExtensionParameter() to the SMTP driver ([email protected], Bug #13764).
- Add a method to obtain the Net_SMTP object from the SMTP driver ([email protected], Bug #13766).
- Prepare 1.2.0a1
chagenbu-20080424214340.txt
(text/plain, 18.2 KB)
http://cvs.php.net/viewvc.cgi/pear/Mail/package.xml?r1=1.59&r2=1.60&diff_format=u Index: pear/Mail/package.xml diff -u pear/Mail/package.xml:1.59 pear/Mail/package.xml:1.60 --- pear/Mail/package.xml:1.59 Sat Dec 8 17:57:54 2007 +++ pear/Mail/package.xml Thu Apr 24 21:43:40 2008 @@ -20,20 +20,19 @@ <email>[email protected]</email> <active>yes</active> </developer> - <date>2007-07-07</date> + <date>2008-04-24</date> <time>22:36:00</time> <version> - <release>1.1.15</release> - <api>1.1.15</api> + <release>1.2.0a1</release> + <api>1.2.0</api> </version> <stability> - <release>stable</release> - <api>stable</api> + <release>alpha</release> + <api>alpha</api> </stability> <license>PHP/BSD</license> - <notes>- Allow turning on SMTP pipelining if the SMTP server and Net_SMTP support it. -- Ensure that setting Return-Path always overrides the envelope sender. -- Add an experimental smtpmx driver (delivers directly to MX servers via SMTP) ([email protected], Bug #5388). + <notes>- Add addServiceExtensionParameter() to the SMTP driver ([email protected], Bug #13764). +- Add a method to obtain the Net_SMTP object from the SMTP driver ([email protected], Bug #13766). </notes> <contents> <dir name="/"> @@ -71,288 +70,4 @@ </optional> </dependencies> <phprelease /> - <changelog> - <release> - <version> - <release>1.1.14</release> - <api>1.1.14</api> - </version> - <stability> - <release>stable</release> - <api>stable</api> - </stability> - <date>2006-10-11</date> - <license>PHP/BSD</license> - <notes>- Fix missing seperation between headers and body in the SMTP driver (Bug #8723). - - </notes> - </release> - <release> - <version> - <release>1.1.13</release> - <api>1.1.13</api> - </version> - <stability> - <release>stable</release> - <api>stable</api> - </stability> - <date>2006-09-14</date> - <license>PHP/BSD</license> - <notes>- Fix _sanitizeHeaders() so that it doesn't eat multiline headers. (Bug 8688, Bug 8699) -- The sendmail backend now correctly writes a blank line between the headers and body text. (Bug 8543) - - </notes> - </release> - <release> - <version> - <release>1.1.12</release> - <api>1.1.12</api> - </version> - <stability> - <release>stable</release> - <api>stable</api> - </stability> - <date>2006-09-13</date> - <license>PHP/BSD</license> - <notes>- Fix typo in _sanitizeHeaders() that blanked out all headers. (Bug 8685) - - </notes> - </release> - <release> - <version> - <release>1.1.11</release> - <api>1.1.11</api> - </version> - <stability> - <release>stable</release> - <api>stable</api> - </stability> - <date>2006-09-12</date> - <license>PHP/BSD</license> - <notes>- Mail::prepareHeaders() no longer appends a trailing newline. (Bug 7492) -- Mail::parseRecipients() now returns a PEAR_Error object on error. (Bug 7491) -- Mail_RFC822::isValidInetAddress() now permits domain parts longer than four characters. The two character minimum remains in effect. (Bug 7562) -- Fixed the tests for the existence of the PHP_EOL constant. (Bug 7682) -- Changed the default 'sendmail_args' value to include the '-i' argument. (Bug 7785) -- We now guard against email injection exploits. (Bug 6229) - - </notes> - </release> - <release> - <version> - <release>1.1.10</release> - <api>1.1.10</api> - </version> - <stability> - <release>stable</release> - <api>stable</api> - </stability> - <date>2006-04-25</date> - <license>PHP/BSD</license> - <notes>- The SMTP driver now includes an error code in its PEAR_Error objects. (Bug 6983) - - </notes> - </release> - <release> - <version> - <release>1.1.9</release> - <api>1.1.9</api> - </version> - <stability> - <release>stable</release> - <api>stable</api> - </stability> - <date>2005-09-13</date> - <license>PHP/BSD</license> - <notes>- SMTP connections are now reset (RSET) when an error occurs. (Bug 5212) -- The SMTP driver now exposes a disconnect() method which forcibly destroys the SMTP connection. (Bug 5372) - - </notes> - </release> - <release> - <version> - <release>1.1.8</release> - <api>1.1.8</api> - </version> - <stability> - <release>stable</release> - <api>stable</api> - </stability> - <date>2005-08-23</date> - <license>PHP/BSD</license> - <notes>- Removing a stray debugging line that snuck into the 1.1.7 release. (Bug 5190) - - </notes> - </release> - <release> - <version> - <release>1.1.7</release> - <api>1.1.7</api> - </version> - <stability> - <release>stable</release> - <api>stable</api> - </stability> - <date>2005-08-21</date> - <license>PHP/BSD</license> - <notes>- Mail_RFC822::isValidInetAddress() now accepts the '+' character in strict local-parts. (Bug 4943) -- The SMTP backend now returns standardized error messages which now include additional error details from the Net_SMTP package. (Bug 4241) -- Mail::factory() now returns object references without generating PHP warnings. -- The SMTP backend now supports a 'persist' parameter which allows the internal SMTP connection object to be reused over multiple calls to the send() method. (Bug 4122) - - </notes> - </release> - <release> - <version> - <release>1.1.6</release> - <api>1.1.6</api> - </version> - <stability> - <release>stable</release> - <api>stable</api> - </stability> - <date>2005-07-12</date> - <license>PHP/BSD</license> - <notes>- Don't emit warnings with PHP 4.4/5.1. - - </notes> - </release> - <release> - <version> - <release>1.1.5</release> - <api>1.1.5</api> - </version> - <stability> - <release>stable</release> - <api>stable</api> - </stability> - <date>2005-06-26</date> - <license>PHP/BSD</license> - <notes>- Unfold long lines before parsing addresses in Mail_RFC822. -- The SMTP driver now supports a 'timeout' value. (Request #3776) -- An array of Received: headers can now be provided. (Bug #4636) - - </notes> - </release> - <release> - <version> - <release>1.1.4</release> - <api>1.1.4</api> - </version> - <stability> - <release>stable</release> - <api>stable</api> - </stability> - <date>2004-09-08</date> - <license>PHP/BSD</license> - <notes>- Header key comparisons are now case-insensitive. (Colin Viebrock) -- Header fields (e.g., 'Cc', 'Bcc') may now be specified as arrays of addresses. (Colin Viebrock) -- PHP5 compatibility fix (Bug #1563). -- PHP4 / Win32 compatibility fix for the 'sendmail' driver (Bug 1881). -- Stricter "local part" parsing for Mail_RFC822 (in accordance with Section 6.2.4 of RFC 822) (Bug 1869). -- The various send() implementations now properly escalate the PEAR_Error object returned by Mail::prepareHeaders() in the event of an invalid header. - - </notes> - </release> - <release> - <version> - <release>1.1.3</release> - <api>1.1.3</api> - </version> - <stability> - <release>stable</release> - <api>stable</api> - </stability> - <date>2004-04-08</date> - <license>PHP/BSD</license> - <notes>- The 'mail' driver now returns a PEAR_Error object on failure. -- The individual drivers no longer include the 'Mail.php' file. If you want to instantiate a driver directly, you'll need to explicitly include the 'Mail.php' file yourself. - - </notes> - </release> - <release> - <version> - <release>1.1.2</release> - <api>1.1.2</api> - </version> - <stability> - <release>stable</release> - <api>stable</api> - </stability> - <date>2003-09-04</date> - <license>PHP/BSD</license> - <notes>The 'localhost' value can now be set in the SMTP driver. - </notes> - </release> - <release> - <version> - <release>1.1.1</release> - <api>1.1.1</api> - </version> - <stability> - <release>stable</release> - <api>stable</api> - </stability> - <date>2003-06-26</date> - <license>PHP/BSD</license> - <notes>Minor fixes with newlines in headers. - </notes> - </release> - <release> - <version> - <release>1.1.0</release> - <api>1.1.0</api> - </version> - <stability> - <release>stable</release> - <api>stable</api> - </stability> - <date>2003-06-21</date> - <license>PHP/BSD</license> - <notes>The Mail package now depends on Net_SMTP 1.1.0 or greater for its SMTP authentication capabilities. - </notes> - </release> - <release> - <version> - <release>1.0.2</release> - <api>1.0.2</api> - </version> - <stability> - <release>stable</release> - <api>stable</api> - </stability> - <date>2002-07-27</date> - <license>PHP/BSD</license> - <notes>Minor additions and changes to RFC822.php. Fixed line terminator issue for smtp.php and set smtp.php to use Return-Path header in place of From header for MAIL FROM: (if supplied) - </notes> - </release> - <release> - <version> - <release>1.0.1</release> - <api>1.0.1</api> - </version> - <stability> - <release>stable</release> - <api>stable</api> - </stability> - <date>2002-07-27</date> - <license>PHP/BSD</license> - <notes>License change for RFC822.php - </notes> - </release> - <release> - <version> - <release>1.0</release> - <api>1.0</api> - </version> - <stability> - <release>stable</release> - <api>stable</api> - </stability> - <date>2002-06-06</date> - <license>PHP/BSD</license> - <notes>Initial release as PEAR package - </notes> - </release> - </changelog> </package> http://cvs.php.net/viewvc.cgi/pear/Mail/Mail/smtp.php?r1=1.31&r2=1.32&diff_format=u Index: pear/Mail/Mail/smtp.php diff -u pear/Mail/Mail/smtp.php:1.31 pear/Mail/Mail/smtp.php:1.32 --- pear/Mail/Mail/smtp.php:1.31 Sat Oct 6 17:00:00 2007 +++ pear/Mail/Mail/smtp.php Thu Apr 24 21:43:40 2008 @@ -42,7 +42,7 @@ * SMTP implementation of the PEAR Mail interface. Requires the Net_SMTP class. * @access public * @package Mail - * @version $Revision: 1.31 $ + * @version $Revision: 1.32 $ */ class Mail_smtp extends Mail { @@ -55,6 +55,13 @@ var $_smtp = null; /** + * The list of service extension parameters to pass to the Net_SMTP + * mailFrom() command. + * @var array + */ + var $_extparams = array(); + + /** * The SMTP host to connect to. * @var string */ @@ -107,14 +114,6 @@ var $timeout = null; /** - * Whether to use VERP or not. If not a boolean, the string value - * will be used as the VERP separators. - * - * @var mixed boolean or string - */ - var $verp = false; - - /** * Turn on Net_SMTP debugging? * * @var boolean $debug @@ -150,6 +149,7 @@ * localhost The local hostname / domain. Defaults to localhost. * timeout The SMTP connection timeout. Defaults to none. * verp Whether to use VERP or not. Defaults to false. + * DEPRECATED as of 1.2.0 (use setMailParams()). * debug Activate SMTP debug mode? Defaults to false. * persist Should the SMTP connection persist? * pipelining Use SMTP command pipelining @@ -170,11 +170,15 @@ if (isset($params['password'])) $this->password = $params['password']; if (isset($params['localhost'])) $this->localhost = $params['localhost']; if (isset($params['timeout'])) $this->timeout = $params['timeout']; - if (isset($params['verp'])) $this->verp = $params['verp']; 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']; + // Deprecated options + if (isset($params['verp'])) { + $this->addServiceExtensionParameter('XVERP', is_bool($params['verp']) ? null : $params['verp']); + } + register_shutdown_function(array(&$this, '_Mail_smtp')); } @@ -204,7 +208,7 @@ * test'. * * @param string $body The full text of the message body, including any - * Mime parts, etc. + * MIME parts, etc. * * @return mixed Returns true on success, or a PEAR_Error * containing a descriptive error message on @@ -216,47 +220,9 @@ include_once 'Net/SMTP.php'; /* If we don't already have an SMTP object, create one. */ - if (is_object($this->_smtp) === false) { - $this->_smtp = new Net_SMTP($this->host, $this->port, - $this->localhost); - - /* If we still don't have an SMTP object at this point, fail. */ - if (is_object($this->_smtp) === false) { - return PEAR::raiseError('Failed to create a Net_SMTP object', - PEAR_MAIL_SMTP_ERROR_CREATE); - } - - if (isset($this->pipelining)) { - $this->_smtp->pipelining = $this->pipelining; - } - - /* Configure the SMTP connection. */ - if ($this->debug) { - $this->_smtp->setDebug(true); - } - - /* Attempt to connect to the configured SMTP server. */ - $res = $this->_smtp->connect($this->timeout); - if (is_a($res, 'PEAR_Error')) { - $error = $this->_error('Failed to connect to ' . - $this->host . ':' . $this->port, - $res); - return PEAR::raiseError($error, PEAR_MAIL_SMTP_ERROR_CONNECT); - } - - /* Attempt to authenticate if authentication has been enabled. */ - if ($this->auth) { - $method = is_string($this->auth) ? $this->auth : ''; - - $res = $this->_smtp->auth($this->username, - $this->password, - $method); - if (is_a($res, 'PEAR_Error')) { - $error = $this->_error("$method authentication failure", $res); - $this->_smtp->rset(); - return PEAR::raiseError($error, PEAR_MAIL_SMTP_ERROR_AUTH); - } - } + $result = &$this->getSMTPObject(); + if (PEAR::isError($result)) { + return $result; } if (!is_array($headers)) { @@ -288,9 +254,13 @@ PEAR_MAIL_SMTP_ERROR_FROM); } - $args['verp'] = $this->verp; - $res = $this->_smtp->mailFrom($from, $args); - if (is_a($res, 'PEAR_Error')) { + $params = null; + if (!empty($this->_extparams)) { + foreach ($this->_extparams as $key => $val) { + $params .= ' ' . $key . (is_null($val) ? '' : '=' . $val); + } + } + if (PEAR::isError($res = $this->_smtp->mailFrom($from, $params))) { $error = $this->_error("Failed to set sender: $from", $res); $this->_smtp->rset(); return PEAR::raiseError($error, PEAR_MAIL_SMTP_ERROR_SENDER); @@ -328,6 +298,76 @@ } /** + * Connect to the SMTP server by instantiating a Net_SMTP object. + * + * @return mixed Returns a reference to the Net_SMTP object on success, or + * a PEAR_Error containing a descriptive error message on + * failure. + * + * @since 1.2.0 + * @access public + */ + function &getSMTPObject() + { + if (is_object($this->_smtp) !== false) { + return $this->_smtp; + } + + $this->_smtp = &new Net_SMTP($this->host, + $this->port, + $this->localhost); + + /* If we still don't have an SMTP object at this point, fail. */ + if (is_object($this->_smtp) === false) { + return PEAR::raiseError('Failed to create a Net_SMTP object', + PEAR_MAIL_SMTP_ERROR_CREATE); + } + + /* Configure the SMTP connection. */ + if ($this->debug) { + $this->_smtp->setDebug(true); + } + + /* Attempt to connect to the configured SMTP server. */ + if (PEAR::isError($res = $this->_smtp->connect($this->timeout))) { + $error = $this->_error('Failed to connect to ' . + $this->host . ':' . $this->port, + $res); + return PEAR::raiseError($error, PEAR_MAIL_SMTP_ERROR_CONNECT); + } + + /* Attempt to authenticate if authentication has been enabled. */ + if ($this->auth) { + $method = is_string($this->auth) ? $this->auth : ''; + + if (PEAR::isError($res = $this->_smtp->auth($this->username, + $this->password, + $method))) { + $error = $this->_error("$method authentication failure", + $res); + $this->_smtp->rset(); + return PEAR::raiseError($error, PEAR_MAIL_SMTP_ERROR_AUTH); + } + } + + return $this->_smtp; + } + + /** + * Add parameter associated with a SMTP service extension. + * + * @param string Extension keyword. + * @param string Any value the keyword needs. + * + * @since 1.2.0 + * @access public + */ + function addServiceExtensionParameter($keyword, $value = null) + { + $this->_extparams[$keyword] = $value; + } + + /** * Disconnect and destroy the current SMTP connection. * * @return boolean True if the SMTP connection no longer exists. @@ -363,11 +403,9 @@ list($code, $response) = $this->_smtp->getResponse(); /* Build our standardized error string. */ - $msg = $text; - $msg .= ' [SMTP: ' . $error->getMessage(); - $msg .= " (code: $code, response: $response)]"; - - return $msg; + return $text + . ' [SMTP: ' . $error->getMessage() + . " (code: $code, response: $response)]"; } }