Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.2.7

Bug #6538 Error on mail send causes infinite send loop
Submitted: 2006-01-20 12:50 UTC
From: nyeholt at gmail dot com Assigned: quipo
Status: Closed Package: Mail_Queue
PHP Version: 4.3.11 OS: RHEL 4
Roadmaps: (Not assigned)    
Subscription  


 [2006-01-20 12:50 UTC] nyeholt at gmail dot com
Description: ------------ The method sendMailsInQueue can get into an infinite loop if there's a send error (and the application doesn't break out on a NOTICE error for some reason, like an overloaded error_handler) as the errornous mail isn't removed from the queue, and is the next one returned from $this->get(). This loops until you start receiving errors from Net::Socket when it gets its connects dropped by the mail server. Test script: --------------- Possible fix if (!PEAR::isError($result)) { $this->container->setAsSent($mail); if($mail->isDeleteAfterSend()) { $this->deleteMail($mail->getId()); } } else { PEAR::raiseError( 'Error in sending mail: '.$result->getMessage(), MAILQUEUE_ERROR_CANNOT_SEND_MAIL, PEAR_ERROR_TRIGGER, E_USER_NOTICE); if($mail->isDeleteAfterSend()) { $this->deleteMail($mail->getId()); } } Or just $this->deleteMail($mail->getId()); Expected result: ---------------- Mail is removed from the queue, subsequent emails processed. Actual result: -------------- 2006-01-20 07:21:39][12:Root User][1024:mysource notice][R] (/usr/share/pear/PEAR.php:763) - Error in sending mail: Failed to send data [SMTP: Invalid response code received from server (code: 554, response: Error: no valid recipients)] [2006-01-20 07:21:39][12:Root User][8:php notice][R] (/usr/share/pear/Net/Socket.php:295) - fwrite(): send of 37 bytes failed with errno=32 Broken pipe [2006-01-20 07:21:39][12:Root User][8:php notice][R] (/usr/share/pear/Net/Socket.php:295) - fwrite(): send of 6 bytes failed with errno=32 Broken pipe

Comments

 [2007-01-20 11:25 UTC] quipo (Lorenzo Alberton)
Partial fix committed to CVS. If there's an error in sendMailsInQueue(), the problematic mail is removed from the internal sending buffer, and the next mail is processed. NB: the mail is not removed from the db since it could be a temporary issue. If you want to remove it, you can do it manually with a custom error handler