Make WordPress Core

Opened 9 years ago

Closed 7 years ago

#3568 closed defect (bug) (invalid)

class-pop3.php does not always correctly read till end-of-mail on mail server

Reported by: fix22 Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.0.5
Component: Administration Keywords:
Focuses: Cc:

Description (last modified by foolswisdom)


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 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 reached.

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!

Change History (10)

comment:1 @fix229 years ago

I noticed it did not place the code correctly so here's all the code blocks used above:


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

while (!feof($fp))

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

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; }

comment:2 @fix229 years ago

  • Milestone 2.2 deleted

comment:3 @foolswisdom9 years ago

  • Description modified (diff)
  • Milestone set to 2.1
  • Severity changed from critical to major

comment:4 @foolswisdom9 years ago

  • Milestone changed from 2.1 to 2.1.1

comment:5 @Nazgul9 years ago

  • Milestone changed from 2.1.1 to 2.1.2

2.1.1 is out, bumping to 2.1.2 milestone.

comment:6 follow-up: @foolswisdom8 years ago

  • Milestone changed from 2.1.3 to 2.4
  • Priority changed from high to normal
  • Severity changed from major to normal

comment:7 in reply to: ↑ 6 @fix228 years ago

Replying to foolswisdom: I see that this has been moved to version 2.4?

comment:8 @foolswisdom8 years ago

fix22, if there is a fix for this issue than please attach the patch, that is likely why set the milestone to 2.4 .

comment:9 @thee177 years ago

  • Milestone changed from 2.5 to 2.6

comment:10 @pishmishy7 years ago

  • Milestone 2.6 deleted
  • Resolution set to invalid
  • Status changed from new to closed

fix22: I'm not sure I completely follow this - do you have an example of a mail that fails to be retrieved? I'll test that with the current code. The regular expression "\.\r\n" checks for the full stop that indicates the end of an SMTP message so I'm not entirely sure why that's not working for you (a message with a "." on a line should actually be represented by ".." and I'm pretty sure that if messages containing a . on a single line in their body were causing problems we'd see a much busier ticket).

I'll close this ticket as invalid until then. Please feel free to reopen.

Note: See TracTickets for help on using tickets.