[imp] SMTP error messages when using the smtp mailer
Per Steinar Iversen
PerSteinar.Iversen at adm.hio.no
Wed Sep 22 01:53:59 PDT 2004
On Tue, 21 Sep 2004, Jan Schneider wrote:
> Zitat von Per Steinar Iversen <PerSteinar.Iversen at adm.hio.no>:
>
>>
>> IMP is not very informative when using the smtp mailer and the messages
>> are rejected by the mailserver. For example, if the test-message eicar.com
>> is sent then the mailserver return "554 5.7.1 Virus..." after the SMTP
>> DATA command has finished and this is reported by IMP as "There was an
>> error sending your message: unable to send data"
>>
>> Is it possible to make IMP report in more detail the message from the
>> mailserver? This would for example be helpful for those trying to mail a
>> virus infected document.
>
> See http://bugs.horde.org/ticket/?id=154
>
> Jan.
For the PHP SMTP mailer a very quick and dirty hack:
--- Net/SMTP.php.bck 2004-09-22 10:28:57.000000000 +0200
+++ Net/SMTP.php 2004-09-22 10:38:22.000000000 +0200
@@ -223,6 +223,7 @@
/* Read the code and store the rest in the arguments array. */
$code = substr($line, 0, 3);
$this->_arguments[] = trim(substr($line, 4));
+ $status_msg = trim(substr($line, 4));
/* Check the syntax of the response code. */
if (is_numeric($code)) {
@@ -252,7 +253,7 @@
}
}
- return new PEAR_Error("Invalid response code received from server");
+ return new PEAR_Error($status_msg);
}
/**
--- Mail/smtp.php.bck 2004-09-22 10:22:17.000000000 +0200
+++ Mail/smtp.php 2004-09-22 10:28:48.000000000 +0200
@@ -203,8 +203,8 @@
}
}
- if (PEAR::isError($smtp->data($text_headers . "\r\n" . $body))) {
- return PEAR::raiseError('unable to send data');
+ if (PEAR::isError($error = $smtp->data($text_headers . "\r\n" . $body))) {
+ return PEAR::raiseError($error);
}
$smtp->disconnect();
This patch is not very much tested at all but seems to behave well when
tested with virus messages and other kinds of messages that are denied by
our mailserver. This seems a bit more user friendly to me, it is possible
to actually see why a message was rejected - assuming that the mailserver
returns reasonable error messages.
Of course this hack is really outside IMP, this is in PEAR.
-psi
More information about the imp
mailing list