cvs: pear /Net_SMTP SMTP.php
| From: | Jon Parise | Date: | Mon, 06 Feb 2006 06:00:22 +0000 |
| Subject: | cvs: pear /Net_SMTP SMTP.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-38014@lists.php.net to get a copy of this message | ||
jon Mon Feb 6 06:00:22 2006 UTC
Modified files:
/pear/Net_SMTP SMTP.php
Log:
Enhancing the mailFrom() and rcptTo() methods to support additional
arbitrary parameters. This allows these methods to be used to support
RFC 1891.
The mailFrom() method's signature has been adjusted to accept its optional
parameter argument as a string instead of an array, for greater flexibility
and future proofing. The array form is still supported for backwards
compatibility.
Bug: #6339
http://cvs.php.net/viewcvs.cgi/pear/Net_SMTP/SMTP.php?r1=1.54&r2=1.55&diff_format=u
Index: pear/Net_SMTP/SMTP.php
diff -u pear/Net_SMTP/SMTP.php:1.54 pear/Net_SMTP/SMTP.php:1.55
--- pear/Net_SMTP/SMTP.php:1.54 Tue Aug 16 03:44:15 2005
+++ pear/Net_SMTP/SMTP.php Mon Feb 6 06:00:22 2006
@@ -18,7 +18,7 @@
// | Damian Alejandro Fernandez Sosa <damlists@cnba.uba.ar> |
// +----------------------------------------------------------------------+
//
-// $Id: SMTP.php,v 1.54 2005/08/16 03:44:15 jon Exp $
+// $Id: SMTP.php,v 1.55 2006/02/06 06:00:22 jon Exp $
require_once 'PEAR.php';
require_once 'Net/Socket.php';
@@ -36,7 +36,6 @@
*/
class Net_SMTP
{
-
/**
* The server to connect to.
* @var string
@@ -666,34 +665,41 @@
/**
* Send the MAIL FROM: command.
*
- * @param string The sender (reverse path) to set.
- *
- * @param array optional arguments. Currently supported:
- * verp boolean or string. If true or string
- * verp is enabled. If string the characters
- * are considered verp separators.
+ * @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.
+ *
+ * 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.
*
* @return mixed Returns a PEAR_Error with an error message on any
* kind of failure, or true on success.
* @access public
* @since 1.0
*/
- function mailFrom($sender, $args = array())
+ function mailFrom($sender, $params = null)
{
- $argstr = '';
+ $args = "FROM:<$sender>";
- if (isset($args['verp'])) {
+ /* Support the deprecated array form of $params. */
+ if (is_array($params) && isset($params['verp'])) {
/* XVERP */
- if ($args['verp'] === true) {
- $argstr .= ' XVERP';
+ if ($params['verp'] === true) {
+ $args .= ' XVERP';
/* XVERP=something */
- } elseif (trim($args['verp'])) {
- $argstr .= ' XVERP=' . $args['verp'];
+ } elseif (trim($params['verp'])) {
+ $args .= ' XVERP=' . $params['verp'];
}
+ } elseif (is_string($params)) {
+ $args .= ' ' . $params;
}
- if (PEAR::isError($error = $this->_put('MAIL',
"FROM:<$sender>$argstr"))) {
+ if (PEAR::isError($error = $this->_put('MAIL', $args))) {
return $error;
}
if (PEAR::isError($error = $this->_parseResponse(250))) {
@@ -706,16 +712,24 @@
/**
* Send the RCPT TO: command.
*
- * @param string The recipient (forward path) to add.
+ * @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.
+ *
* @access public
* @since 1.0
*/
- function rcptTo($recipient)
+ function rcptTo($recipient, $params = null)
{
- if (PEAR::isError($error = $this->_put('RCPT',
"TO:<$recipient>"))) {
+ $args = "TO:<$recipient>";
+ if (is_string($params)) {
+ $args .= ' ' . $params;
+ }
+
+ if (PEAR::isError($error = $this->_put('RCPT', $args))) {
return $error;
}
if (PEAR::isError($error = $this->_parseResponse(array(250, 251)))) {