WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#17001 closed defect (bug) (wontfix)

wp_notify_postauthor From: problem

Reported by: dglingren Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.1
Component: Mail Keywords:
Focuses: Cc:

Description

My application uses the "Email me whenever anyone posts a comment" feature in the Discussion Settings sub panel. I have found an issue with the default WordPress implementation of this feature.

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:

$wp_email = 'wordpress@' . preg_replace('#^www\.#', '', strtolower($_SERVER['SERVER_NAME']));

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:

if ( '' != $comment->comment_author_email )
  $wp_email = $comment->comment_author_email;
else
  $wp_email = 'wordpress@' . preg_replace('#^www\.#', '', strtolower($_SERVER['SERVER_NAME']));

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.

Change History (3)

comment:1 ryan3 years ago

#1593 is the reason why it is done this way. Many ISPs block a from address that is off domain.

comment:2 dglingren3 years ago

  • Resolution set to wontfix
  • Status changed from new to closed

Thank you for gently pointing me back to Ticket #1593, which I should have read more carefully before re-opening this issue. I also found #2053 and #4658 to be illuminating.

I confused myself further by using an internal test server, so of course $_SERVER\['SERVER_NAME'\] was not a valid domain name.

I accept the comment in #2053 that "that there is no reliable way to generate a valid 'From:' header."

Last edited 3 years ago by dglingren (previous) (diff)

comment:3 ocean903 years ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.