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

Bug #17865 Mail hangs when "Allowed memory size of bytes exhausted" error using smtp
Submitted: 2010-09-14 11:47 UTC
From: hloeung Assigned: alec
Status: Closed Package: Mail (version 1.2.0)
PHP Version: 5.1.6 OS: Linux
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 48 - 47 = ?

 
 [2010-09-14 11:47 UTC] hloeung (Haw Loeung)
Description: ------------ It seems that the Mail class hangs when we're using the "smtp" driver and hit the "Allowed memory size of bytes exhausted" error. For example, we currently have "memory_limit" set to 40M in /etc/php.ini. When we try to send a 5MB file, this is what happens: === # php test_mail.php DEBUG: Recv: 220 mail.tpg.com.au ESMTP (mail7) Sendmail ready. DEBUG: Send: EHLO localhost DEBUG: Recv: 250-mail7.tpgi.com.au Hello web- http1.tpgi.com.au [203.12.160.14], pleased to meet you DEBUG: Recv: 250-ENHANCEDSTATUSCODES DEBUG: Recv: 250-PIPELINING DEBUG: Recv: 250-8BITMIME DEBUG: Recv: 250-SIZE 28521268 DEBUG: Recv: 250-DSN DEBUG: Recv: 250-AUTH LOGIN PLAIN DEBUG: Recv: 250-STARTTLS DEBUG: Recv: 250-DELIVERBY DEBUG: Recv: 250 HELP DEBUG: Send: MAIL FROM:<hawl@tpg.com.au> DEBUG: Recv: 250 2.1.0 <hawl@tpg.com.au>... Sender ok DEBUG: Send: RCPT TO:<hawl@tpg.com.au> DEBUG: Recv: 250 2.1.5 <hawl@tpg.com.au>... Recipient ok DEBUG: Send: DATA DEBUG: Recv: 354 Enter mail, end with "." on a line by itself PHP Fatal error: Allowed memory size of 41943040 bytes exhausted (tried to allocate 11211639 bytes) in /usr/share/pear/Net/SMTP.php on line 890 DEBUG: Send: QUIT === From the above, the SMTP transaction gets stuck on the "DATA" part because it is expecting a "." on a line by itself to signal end of data. Test script: --------------- <?php require_once "Mail.php"; $from = "H <hawl@tpg.com.au>"; $to = "H <hawl@tpg.com.au>"; $subject = "Hi!"; $headers = array ('From' => $from, 'To' => $to, 'Subject' => $subject); $fh = fopen('/home/shared/tmp/body.txt', 'r'); $body = fread($fh, filesize('/home/shared/tmp/body.txt'));; fclose($fh); $smtp = Mail::factory('smtp', array ('host' => 'mail.tpg.com.au', 'debug' => '1')); $mail = $smtp->send($to, $headers, $body); if (PEAR::isError($mail)) { echo("<p>" . $mail->getMessage() . "</p>"); } else { echo("<p>Message successfully sent!</p>"); } ?> Expected result: ---------------- The script should terminate instead of hanging at the DATA stage of an SMTP transaction. Actual result: -------------- DEBUG: Recv: 354 Enter mail, end with "." on a line by itself PHP Fatal error: Allowed memory size of 41943040 bytes exhausted (tried to allocate 11211639 bytes) in /usr/share/pear/Net/SMTP.php on line 890 DEBUG: Send: QUIT

Comments

 [2011-01-08 14:54 UTC] alec (Aleksander Machniak)
-Status: Open +Status: Closed -Assigned To: +Assigned To: alec
I'm closing this, because some fixes has been made in Net_SMTP package to prevent such situations. This was not Mail package issue.
 [2011-01-17 13:17 UTC] hloeung (Haw Loeung)
After further investigation, it seems this is an issue with Net_SMTP where it would hang reading a reply code from the SMTP server. I have submitted a patch to Net_SMTP adding a timeout if no reply code could be read. See http://pear.php.net/bugs/bug.php?id=18197 Alec, thank you for your time and sorry I didn't look into it further.