Make WordPress Core

Changes between Initial Version and Version 1 of Ticket #16995


Ignore:
Timestamp:
03/29/2011 08:39:04 PM (13 years ago)
Author:
scribu
Comment:

It's not a good idea to lump two issues in the same ticket.

Please open a new ticket for the first issue.

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #16995

    • Property Keywords needs-patch added
    • Property Milestone changed from Awaiting Review to Future Release
    • Property Summary changed from wp_notify_postauthor From: problem and pluggable behavior problem to wp_notify_postauthor() pluggable behavior problem
  • Ticket #16995 – Description

    initial v1  
    1 My application uses the "Email me whenever anyone posts a comment" feature in the Discussion Settings sub panel. I have found two issues with the default WordPress implementation of this feature.
    2 
    3 First, WordPress puts an invalid e-mail address in the "From:" header of all messages. In wp-includes/pluggable.php, function wp_notify_postauthor, line 1072 reads:
    4 
    5 {{{
    6 $wp_email = 'wordpress@' . preg_replace('#^www\.#', '', strtolower($_SERVER['SERVER_NAME']));
    7 }}}
    8 
    9 This means that the "From" field on all comment notification e-mails will contain an invalid domain name, which causes some SMTP servers to reject the transmission. A fix is to use the comment author's e-mail address when it is available:
    10 
    11 {{{
    12 if ( '' != $comment->comment_author_email )
    13   $wp_email = $comment->comment_author_email;
    14 else
    15   $wp_email = 'wordpress@' . preg_replace('#^www\.#', '', strtolower($_SERVER['SERVER_NAME']));
    16 }}}
    17 
    18 There are some old (2005) tickets on this issue (e.g., #2053, #1593, #1532), and Changeset 3214 comes close. However, the fix proposed here brings the "From:" address into line with the "Reply-To:" address and is a better fix when the comment_author_email is set.
    19 
    20 Second, in my application  a notification must be issued even when an author comments on their own post; this is not allowed by the default WordPress implementation. Lines 1015 - 1025 in function wp_notify_postauthor reject the author's comments and moderations.
     1In my application  a notification must be issued even when an author comments on their own post; this is not allowed by the default WordPress implementation. Lines 1015 - 1025 in function wp_notify_postauthor reject the author's comments and moderations.
    212Since wp_notify_postauthor is a pluggable function, I can change this behavior by implementing my own function and replacing the default.
    223