Synchronization issues with qmail

Synchronization issues with qmail

by Brian Koontz -
Number of replies: 0
Just a heads' up:  There appears to be some serious synchronization issues when using phpmailer and qmail.  Specifically, qmail and phpmailer appear to get out of sync when there is a delay on the server (MTA) side; phpmailer eventually errors out because the return codes are not as expected.

The undocumented 'qmail' hack in smtphosts is fine if you are using a local qmail MTA, but doesn't appear to help when connecting to a remote host using qmail as its MTA.  (For instance, when running Moodle on a system that doesn't have (or need) an MTA running.)

Here's a symptom of the problem (debugging enabled in class.phpmailer.php):

Server Time: Fri, 10 Dec 2004 22:00:07 -0600


Starting activity modules
Processing module function assignment_cron ...Processing assignment submission 5
SMTP -> FROM SERVER:
SMTP -> FROM SERVER:
220 pongonova.net ESMTP
SMTP -> FROM SERVER:
250-pongonova.net
250-PIPELINING
250 8BITMIME
SMTP -> FROM SERVER:
250 ok
SMTP -> FROM SERVER:
250 ok
SMTP -> ERROR: DATA command not accepted from server: 250 ok

SMTP -> FROM SERVER:
354 go ahead
SMTP -> ERROR: RSET failed: 354 go ahead

ERROR: SMTP Error: Data not accepted.

The following patch appears to resolve the synchronization issue:

*** lib/phpmailer/class.smtp.php	2004/12/11 03:05:15	1.1
--- lib/phpmailer/class.smtp.php 2004/12/11 04:06:03
***************
*** 274,281 ****

fputs($this->smtp_conn,"DATA" . $this->CRLF);

! $rply = $this->get_lines();
! $code = substr($rply,0,3);

if($this->do_debug >= 2) {
echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
--- 274,284 ----

fputs($this->smtp_conn,"DATA" . $this->CRLF);

! $code = 0;
! while( $code == 0 || $code == 250 ) {
! $rply = $this->get_lines();
! $code = substr($rply,0,3);
! }

if($this->do_debug >= 2) {
echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;

Here's the output with the patch:

Server Time: Fri, 10 Dec 2004 22:06:29 -0600


Starting activity modules
Processing module function assignment_cron ...Processing assignment submission 5
SMTP -> FROM SERVER:
SMTP -> FROM SERVER:
SMTP -> ERROR: EHLO not accepted from server:
SMTP -> FROM SERVER:
220 pongonova.net ESMTP
SMTP -> FROM SERVER:
250-pongonova.net
250-PIPELINING
250 8BITMIME
SMTP -> FROM SERVER:
250 pongonova.net
SMTP -> FROM SERVER:
354 go ahead
SMTP -> FROM SERVER:
250 ok 1102738015 qp 303
SMTP -> FROM SERVER:
221 pongonova.net
done.


Average of ratings: -