diff --git a/src/wp-includes/pluggable.php b/src/wp-includes/pluggable.php index 1d5ee194c9f10..d1a18fd40e1ba 100644 --- a/src/wp-includes/pluggable.php +++ b/src/wp-includes/pluggable.php @@ -444,7 +444,9 @@ function wp_mail( $to, $subject, $message, $headers = '', $attachments = array() $from_name = apply_filters( 'wp_mail_from_name', $from_name ); try { - $phpmailer->setFrom( $from_email, $from_name ); + // Passing $auto can be removed once PHPMailer supports setting the envelope sender separately. See . + $auto = ! str_contains( ini_get( 'sendmail_path' ), ' -f' ); + $phpmailer->setFrom( $from_email, $from_name, $auto ); } catch ( PHPMailer\PHPMailer\Exception $e ) { $mail_error_data = compact( 'to', 'subject', 'message', 'headers', 'attachments' ); $mail_error_data['phpmailer_exception_code'] = $e->getCode();