Make WordPress Core

Opened 5 years ago

Closed 5 years ago

#51206 closed defect (bug) (duplicate)

wp_mail() not setting Sender address on PhpMailer->setFrom()

Reported by: lordandy1984's profile lordandy1984 Owned by:
Milestone: Priority: normal
Severity: normal Version: 5.5
Component: Mail Keywords: has-patch
Focuses: Cc:

Description

The function wp_mail() is using PhpMailers setFrom method to configure the from address.

But it is setting the last parameter ($auto) to false, meaning the real envelope address it not being set.
Depending on the server configuration of the PHP mail() and sendmail installation, this might lead to the script using some weird default user/domain configuration.

Is there a reason not to leave the third parameter to the default value? It would then really use the sender address the user enters (e.g. in a GravityForm notification), and not something the server/hosting has configured or misconfigured?

wp_mail() setting the from address:

<?php
$phpmailer->setFrom( $from_email, $from_name, false );

PhpMailer setFrom method:

<?php
//@param bool $auto Whether to also set the Sender address, defaults to true
setFrom($address, $name = '', $auto = true)

Change History (2)

This ticket was mentioned in PR #511 on WordPress/wordpress-develop by aadlung.


5 years ago
#1

  • Keywords has-patch added

Removed the false of $phpmailer->setFrom( $from_email, $from_name, false ) which is the $auto parameter of PhpMailer to also set the Sender address to the same value the From address has been specified.
Currently, the false leads to some www-data sending addresses on default domains which are marked as spam. For sure, it depends on the hosting or sendmail configuration - but the default would be better.

Trac ticket: https://core.trac.wordpress.org/ticket/51206

#2 @SergeyBiryukov
5 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Hi there, welcome to WordPress Trac! Thanks for the ticket and the PR.

We're already tracking this issue in #49687.

Note: See TracTickets for help on using tickets.