Support » Fixing WordPress » Can’t automate email-post-checking

  • Hi –
    I’ve tried to set up a cron to automate checking of wp-mail.php however even when I just test it from the command line, it doesn’t seem to work properly. I get the following:
    Server:/etc matt$ wget
    => wp-mail.php’
    Connecting to… connected.
    HTTP request sent, awaiting response… 200 OK
    Length: unspecified [text/html]
    wp-mail.php: Permission denied
    Cannot write to
    wp-mail.php’ (Permission denied).
    Any ideas?
    When I put the URL into a web browser, the page loads and functions fine.
    TIA –

Viewing 12 replies - 1 through 12 (of 12 total)
  • Update: Posting seems to work but the default wp-mail.php is not removing the mail from the account after it posts it. So every time wp-mail checks the account, it reposts messages its already posted. Any idea why?

    Same problem here – I set cron to run every 5 minutes, and wp-mail.php keeps on fetching the same email (because it didn’t delete after fetching it).
    Any pointers will be appreciated.

    I also have the post problem. I doesn’t happen every time, but when it does happen, the email-post doesn’t get a category, but I see an error or two….
    1. When running the mail.php manually, it will tell me that Oops, could not delete. “Oops POP3 delete: Command failed [-ERR No such message]”. Of course at this point I will end up with multiple identical posts. Identical except that every subsequent email is tacked on.
    Email #1 – #3
    Post #1 contains Email #1
    Post #2 contains Email #2, #1
    Post #3 contains Email #3, #2, #1
    2. Well, as these things go, I couldn’t get the software the create the category problem. As memory serves, the error that appears in the wp-admin/edit.php screen is around line 90, no category specified.
    I do have a default category and when the email to post works it gets the default category, just like it should.

    Has there been a resolution for this issue? I’m having the same problem.





    Seevral problems have been identified with post-by-email. Please take a look at ticket 1480. Feel free to assist by adding feedback (and patches!).

    First, thanks for the quick reply.

    Second, I’ve been running WP for a couple months using the cron job to automatically run wp-mail, and it has worked beautifully, I’m trying to figure out why this just started out of the blue. Has anyone had this happen?




    Have any changes taken place at the mail server? Has the POP3 daemon been replaced with a new version, or replaced by a different daemon?

    Well, I’ve solved my problem, with further investigation, I found there was a MySQL error when trying to insert the post into the database. It was getting fouled up on a quote ‘ in the word ‘don’t’ – don’t know why this happened, but when I took it out, it worked. So there were more than one error going on, and fixing the first error in turn, fixed the subsequent deletion problem.

    the blog is at

    i cant find anything at all that resolves this problem and have no idea how to fix it. it seems that loads of us have the same issue where email is not being deleted once it has been read by a wordpress.

    this is killing me – there is no way i can blog by mail with it the way it is now.

    does anyone anywhere have a solution for this at all.

    please, please, please can someone somewhere help?




    I’ve got this problem now. I am using the wp-postie plugin and I had the SQL error that stopha described as well, so I fixed the quote (‘) issue, and that resolved it I thought, but when I did today a check run on wp-postie it says:

    #!/usr/bin/php -q

    Connecting to (pop3))
    Mission complete, message 1 deleted.
    Oops POP3 delete: Command failed []\n

    So it looks like it’s still an issue – please help!!!

    the blog is at



    Found a fix:

    1) open ‘postie-functions.php’ in /wp-content/plugins/postie
    2) edit the following on line 56:
    ‘post_title’ => $subject,
    ‘post_title’ => preg_replace(“/’/”,”\'”,$subject),

    This changes the ‘ into \’ – and that was the issue. This should be updated in the source as well – programmers please review this

    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 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!

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Can’t automate email-post-checking’ is closed to new replies.