[wp-trac] [WordPress Trac] #49687: wp_mail() - Why is no envelope sender defined?
WordPress Trac
noreply at wordpress.org
Fri Dec 5 00:15:21 UTC 2025
#49687: wp_mail() - Why is no envelope sender defined?
--------------------------------------------------+-----------------------
Reporter: vbbp | Owner: SirLouen
Type: enhancement | Status: closed
Priority: normal | Milestone: 6.9
Component: Mail | Version: 5.4
Severity: major | Resolution: fixed
Keywords: has-test-info has-patch has-dev-note | Focuses:
--------------------------------------------------+-----------------------
Comment (by SirLouen):
Replying to [comment:45 siliconforks]:
> It's conceivable that it might be the issue I mentioned above:
>
> https://core.trac.wordpress.org/ticket/49687#comment:23
I'm not sure why this is conflicting
{{{#!php
<?php
if (!empty($this->Sender) && static::validateAddress($this->Sender)) {
if (self::isShellSafe($this->Sender)) {
$params = sprintf('-f%s', $this->Sender);
}
$old_from = ini_get('sendmail_from');
ini_set('sendmail_from', $this->Sender);
}
}}}
So, I wonder if the user is receiving the `More than one "from" person`
error also.
If the user has the `sendmail_from` set in his `php.ini`, PHPMailer should
overwrite it. But if they are forcing the `-f` in the `sendmail_path` this
is a complete misconfiguration of the server (because for this purpose,
there is a `sendmail_from`).
The reality is that the problem comes, when people have their `sendmail`
`from` already set up for whatever reason. In this case, now two `From`
addresses will be conflicting. Noone who could have had troubles with the
`Sender` address because of this bug, should have been using the default
behaviour if they pretended to add `-f` enabled in their sendmail. I
understand that the Mail component has been a little abandoned for years
and people were resorting to whatever worked the best. But instead, they
should have switched to `isSendMail`. But since we were disabling the
`Sender` option here, the regular `mail` was too permissive and was
enabling sending mails with regular `mail` wrongly (this is not acceptable
according to the PHP docs).
Here there are two quick solutions:
1. Ideally if you want to keep your sendmail server configuration, or you
cannot modify it because its a webhost, switch to `isSendMail` this code
inside a plugin or `functions.php`
{{{#!php
<?php
function use_sendmail( $phpmailer ) {
$phpmailer->isSendMail();
}
add_action( 'phpmailer_init', 'use_sendmail' );
}}}
2. Removing the sender address from the `sendmail_path` parameter in your
`php.ini` file. Check if your `sendmail_path` is adding a `-f`.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/49687#comment:46>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list