cvs: php4 /pear/Mail smtp.php /pear/Net SMTP.php
| From: | Chuck Hagenbuch | Date: | Fri, 17 Aug 2001 21:39:44 +0000 |
| Subject: | cvs: php4 /pear/Mail smtp.php /pear/Net SMTP.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-565@lists.php.net to get a copy of this message | ||
chagenbu Fri Aug 17 17:39:44 2001 EDT
Modified files:
/php4/pear/Mail smtp.php
/php4/pear/Net SMTP.php
Log:
Return an error when relaying is denied (or the RCPT TO: command fails for
any reason), and be more useful about the error message that is returned, as
well.
Index: php4/pear/Mail/smtp.php
diff -u php4/pear/Mail/smtp.php:1.6 php4/pear/Mail/smtp.php:1.7
--- php4/pear/Mail/smtp.php:1.6 Wed Aug 8 20:53:56 2001
+++ php4/pear/Mail/smtp.php Fri Aug 17 17:39:44 2001
@@ -23,7 +23,7 @@
* Net_SMTP:: class.
* @access public
* @package Mail
- * @version $Revision: 1.6 $
+ * @version $Revision: 1.7 $
*/
class Mail_smtp extends Mail {
@@ -129,7 +129,7 @@
$recipients = $this->parseRecipients($recipients);
foreach($recipients as $recipient) {
- if (!$smtp->rcptTo($recipient)) { return new PEAR_Error('unable to add
recipient [' . $recipient . ']'); }
+ if (PEAR::isError($res = $smtp->rcptTo($recipient))) { return new
PEAR_Error('unable to add recipient [' . $recipient . ']: ' .
$res->getMessage()); }
}
if (!$smtp->data($text_headers . "\n" . $body)) { return new
PEAR_Error('unable to send data'); }
Index: php4/pear/Net/SMTP.php
diff -u php4/pear/Net/SMTP.php:1.3 php4/pear/Net/SMTP.php:1.4
--- php4/pear/Net/SMTP.php:1.3 Wed May 30 22:33:05 2001
+++ php4/pear/Net/SMTP.php Fri Aug 17 17:39:44 2001
@@ -61,6 +61,12 @@
var $esmtp;
/**
+ * The last line read from the server.
+ * @var string
+ */
+ var $lastline;
+
+ /**
* Constructor
*
* Instantiates a new Net_SMTP object, overriding any defaults
@@ -183,7 +189,7 @@
/* Note: 251 is also a valid response code */
if (PEAR::isError($this->socket->write("RCPT TO:<$forward_path>\r\n"))) {
return new PEAR_Error('write to socket failed'); }
- if (!($this->validateResponse('250'))) { return new PEAR_Error('250 OK not
received'); }
+ if (!($this->validateResponse('250'))) { return new PEAR_Error($this->lastline);
}
return true;
}
@@ -339,13 +345,13 @@
* @access private
*/
function validateResponse($code) {
- while ($response = $this->socket->readLine()) {
- $reply_code = strtok($response, ' ');
+ while ($this->lastline = $this->socket->readLine()) {
+ $reply_code = strtok($this->lastline, ' ');
if (!(strcmp($code, $reply_code))) {
$this->code = $reply_code;
return true;
} else {
- $reply_code = strtok($response, '-');
+ $reply_code = strtok($this->lastline, '-');
if (strcmp($code, $reply_code)) {
$this->code = $reply_code;
return false;
@@ -371,20 +377,20 @@
function validateAndParseResponse($code, &$arguments) {
$arguments = array();
- while ($response = $this->socket->readLine()) {
- $reply_code = strtok($response, ' ');
+ while ($this->lastline = $this->socket->readLine()) {
+ $reply_code = strtok($this->lastline, ' ');
if (!(strcmp($code, $reply_code))) {
- $arguments[] = substr($response, strlen($code) + 1, strlen($response) - strlen($code) - 1);
+ $arguments[] = substr($this->lastline, strlen($code) + 1, strlen($this->lastline) -
strlen($code) - 1);
$this->code = $reply_code;
return true;
} else {
- $reply_code = strtok($response, '-');
+ $reply_code = strtok($this->lastline, '-');
if (strcmp($code, $reply_code)) {
$this->code = $reply_code;
return false;
}
}
- $arguments[] = substr($response, strlen($code) + 1, strlen($response) - strlen($code) - 1);
+ $arguments[] = substr($this->lastline, strlen($code) + 1, strlen($this->lastline) -
strlen($code) - 1);
}
return false;