WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 2 years ago

#18923 closed defect (bug) (fixed)

Publish by email stuck in Pending status

Reported by: bloggertype Owned by: nacin
Milestone: 3.4 Priority: normal
Severity: normal Version: 3.2.1
Component: Blog by Email Keywords: has-patch needs-testing commit
Focuses: Cc:

Description

This seems to be an ongoing issue faced by people for publishing posts by email.

Environment:

  • Wordpress.org 3.2.1
  • Thunderbird 7.1 email client; publish messages sent in text mode, with word wrap off

Steps:
1) User from which posts sent is registered as Editor or Admin in Wordpress site.
2) Theme footer modified to include automatic checking for incoming messages
3) Email account is setup in mail client that matches the Admin/Editor email in Wordpress
4) Message to post is sent to the secret address by user

Result:
1) Wordpress gets the message, but message is stuck in Pending status. This happens for all messages sent by user from email client.
2) This happens if user is Admin or Editor, doesn't make difference.

Note: I use Google Apps as the email server for both the From: mail and the secret address mail. If I use the Google webmail interface to send (again from the From address to the To address) rather than a mail client, it does not get stuck in Pending and gets published by Wordpress properly (although with formatting problems, but that is a separate issue). So issue occurs only from any email client (Thunderbird, Outlook, etc.)

Workaround:
Modify the wp-mail.php file so that it disables the email account check. The Pending line is changed to Publish if it fails the check in the wp-mail.php file.
This works and posts do get published, but no longer verifies the user's permission for publishing to the blog.

I don't know if the problem originates in the wp-mail.php file itself or some dependency (am not a php developer)

Related Support Forum post:
This seems to be an issue people have been having for previous versions.
http://wordpress.org/support/topic/blog-by-email-posts-stuck-in-pending-review

I am surprised that I have not found a bug already filed on this (or maybe I missed it).

Attachments (2)

18923.diff (1.2 KB) - added by solarissmoke 2 years ago.
18923.2.diff (1.3 KB) - added by solarissmoke 2 years ago.

Download all attachments as: .zip

Change History (10)

comment:1 solarissmoke3 years ago

  • Keywords reporter-feedback added

Could you please supply the message headers for the message sent using Thunderbird as well as the message sent using Gmail?

comment:2 in reply to: ↑ description bloggertype3 years ago

Thunderbird header:

Return-Path: <blogpost@mediaideas.net>
Received: from [127.0.0.1] ([122.163.40.43])        by mx.google.com with ESMTPS id v8sm15409980pbf.8.2011.10.19.23.12.54        (version=SSLv3 cipher=OTHER);        Wed, 19 Oct 2011 23:12:56 -0700 (PDT)
Message-ID: <4E9FBBF2.9020206@mediaideas.net>
Date: Thu, 20 Oct 2011 11:43:06 +0530
From: Blog Posting <blogpost@mediaideas.net>
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:7.0.1) Gecko/20110929 Thunderbird/7.0.1
MIME-Version: 1.0
To: wpblog350@mediaideas.net
Subject: BoSacks Speaks Out: The End of Communication As We Know It
References: <1108216728855.1101283694210.9887.5.53002509@scheduler>
In-Reply-To: <1108216728855.1101283694210.9887.5.53002509@scheduler>
X-Forwarded-Message-Id: <1108216728855.1101283694210.9887.5.53002509@scheduler>
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

Google header (from webmail):

Return-Path: <blogpost@mediaideas.net>
Received: from [127.0.0.1] ([122.163.40.43])
        by mx.google.com with ESMTPS id v8sm15409980pbf.8.2011.10.19.23.12.54
        (version=SSLv3 cipher=OTHER);
        Wed, 19 Oct 2011 23:12:56 -0700 (PDT)
Message-ID: <4E9FBBF2.9020206@mediaideas.net>
Date: Thu, 20 Oct 2011 11:43:06 +0530
From: Blog Posting <blogpost@mediaideas.net>
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:7.0.1) Gecko/20110929 Thunderbird/7.0.1
MIME-Version: 1.0
To: wpblog350@mediaideas.net
Subject: BoSacks Speaks Out: The End of Communication As We Know It
References: <1108216728855.1101283694210.9887.5.53002509@scheduler>
In-Reply-To: <1108216728855.1101283694210.9887.5.53002509@scheduler>
X-Forwarded-Message-Id: <1108216728855.1101283694210.9887.5.53002509@scheduler>
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Last edited 3 years ago by SergeyBiryukov (previous) (diff)

solarissmoke2 years ago

comment:3 solarissmoke2 years ago

  • Keywords has-patch needs-testing added; reporter-feedback removed

I think I've tracked this down. The problem is the following regex in wp-mail.php:

preg_match('/(From|Reply-To): /', $line)

This also matches In-Reply-To: headers because it doesn't check for the start of the line. And because of the way the logic works, if an In-Reply-To: header comes after a From: header, then the author gets overwritten (regardless of whether the author is identifiable as a user), and then the post goes into pending status.

Patch fixes the regex, also removes some redundant else blocks.

comment:4 mighty_mt2 years ago

This problem is still valid and it's quite annoying.

@solarissmoke: Thanks a lot for the patch! I just tried it now and so far it seems to work as expected. Hope this get included with one of the next core updates.

By the way, I'm currently using WordPress 3.3.1 and Thunderbird 10.0

comment:5 SergeyBiryukov2 years ago

  • Milestone changed from Awaiting Review to 3.4

solarissmoke2 years ago

comment:6 solarissmoke2 years ago

  • Component changed from Mail to Blog by Email

Have tweaked the patch with a slightly better regex.

comment:7 nacin2 years ago

  • Keywords commit added

comment:8 nacin2 years ago

  • Owner set to nacin
  • Resolution set to fixed
  • Status changed from new to closed

In [20682]:

Anchor a regular expression in wp-mail.php to ensure we are matching the Reply-To: header, not the In-Reply-To: header.

Per RFCs *822, mail headers must start at the beginning of a line. This same pattern could be continued throughout this file.

props solarissmoke.
fixes #18923.

Note: See TracTickets for help on using tickets.