[wp-trac] [WordPress Trac] #3568: class-pop3.php does not always correctly read till end-of-mail on mail server

WordPress Trac wp-trac at lists.automattic.com
Fri Jan 12 09:13:22 GMT 2007

#3568: class-pop3.php does not always correctly read till end-of-mail on mail
 Reporter:  fix22           |       Owner:  anonymous
     Type:  defect          |      Status:  new      
 Priority:  high            |   Milestone:  2.2      
Component:  Administration  |     Version:  2.0.5    
 Severity:  critical        |    Keywords:           

 Found out some more info on this as the fix above does not fix all issues.
 It only worked for some e-mails that had a subject line with a "'" in it.

 Also - You need to do the same for the $content variable too if you
 haven't done that:


 I still had the issue on [http://advertising-info.org/ advertising-
 info.org] so I started throubleshooting some more. It has cost me about 10
 hours to find what the issue was. Finally I found it (it's a bug in the
 standard wordpress code and it is up to 2.0.5 so I got to report this to
 the wp coders as well):

 In class-pop3.php (in /wp-includes/) there is the following line in the
 function "get":

 while ( !ereg("^\.\r\n",$line))

 This is incorrect! What happens I think is the following: if a certain
 message had a "." on a newline (I think this may happen for instance if
 the "." was just cut-off by the the max lenght of the line and was
 therefore placed on the next line, or when someone just placed a dot on a
 line and then a \r\n return/newline.)

 To fix this issue: swap the above to this:

 while (!feof($fp))

 While in fact this will not do much (I do not think that the mail server
 will actually report an end-of-file) the following piece of the "get"
 function will now kick-in;

 if(empty($line)) { break; }

 And stop reading from the mail server when the end of the message was

 So the actual issue was that the mail server was unable to delete the
 message as the message was not completely read and was still being
 processed. That is where the error "Oops POP3 delete: Command Failed []\n"
 comes from (it cannot delete the message since it is still open and it
 will not give an error ("[]") because it cannot do (delete) what the
 postie-functions.php is asking it to do (delete the messsage).

 I tested this on the message that was failing (line 52 had just a "." on
 it) and it worked!

 If you want to test for yourself if this is the issue you are having,
 simply change the code in class-pop3.php to the following:

 while (!feof($fp))

 $MsgArray[$count] = $line;
 $line = fgets($fp,$buffer);
 echo "Read mail line".$count.": ".$line."\n";
 if(empty($line)) {
 echo "Read mail line - Break Issued\n";
 break; }

 This will output all the lines while reading from the mail server (you can
 see the output of this by manually runing postie from the options in WP)

 Hope this helps!

Ticket URL: <http://trac.wordpress.org/ticket/3568>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software

More information about the wp-trac mailing list