-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add: MAIL_ENVELOP_FROM constant for flexible email Sender header mana… #8299
base: trunk
Are you sure you want to change the base?
Conversation
Trac Ticket MissingThis pull request is missing a link to a Trac ticket. For a contribution to be considered, there must be a corresponding ticket in Trac. To attach a pull request to a Trac ticket, please include the ticket's full URL in your pull request description. More information about contributing to WordPress on GitHub can be found in the Core Handbook. |
Hi @nzsys! 👋 Thank you for your contribution to WordPress! 💖 It looks like this is your first pull request to No one monitors this repository for new pull requests. Pull requests must be attached to a Trac ticket to be considered for inclusion in WordPress Core. To attach a pull request to a Trac ticket, please include the ticket's full URL in your pull request description. Pull requests are never merged on GitHub. The WordPress codebase continues to be managed through the SVN repository that this GitHub repository mirrors. Please feel free to open pull requests to work on any contribution you are making. More information about how GitHub pull requests can be used to contribute to WordPress can be found in the Core Handbook. Please include automated tests. Including tests in your pull request is one way to help your patch be considered faster. To learn about WordPress' test suites, visit the Automated Testing page in the handbook. If you have not had a chance, please review the Contribute with Code page in the WordPress Core Handbook. The Developer Hub also documents the various coding standards that are followed:
Thank you, |
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @nzsys. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. Core Committers: Use this line as a base for the props when committing in SVN:
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
Noting that you can already change the sender by using the |
Thank you for your feedback. I understand that the sender can be changed using the phpmailer_init hook. However, since this is a theme or plugin-level setting, it may not be sufficient to ensure consistency across the entire site. Therefore, I believe allowing this to be configured in wp-config.php would be more appropriate, as it ensures consistency at the software level (across WordPress) and makes it easier to manage. |
Summary
This pull request introduces a new
MAIL_ENVELOP_FROM
constant to allow better control of the "Sender" header in outgoing emails.Why is this important ?
Using a properly configured sender email is essential for meeting SPF / DKIM requirements, improving deliverability, and avoiding spoofing issues.
To adopt this feature, users can define the
MAIL_ENVELOP_FROM
constant inwp-config.php
.This configuration is especially beneficial in multisite environments, where dynamic Sender values may be needed.Changes
Core logic changes
Updated
wp-includes/pluggable.php
to set PHPMailer’sSender
property based on theMAIL_ENVELOP_FROM
constant(if defined).Added tests to cover cases where
MAIL_ENVELOP_FROM
is defined and where it is not.Why
The "Sender" header is critical for the following reasons:
SPF and DKIM Authentication
Ensures emails are not flagged as spoofed by third parties.Accurate and consistent Sender addresses are necessary to meet the requirements for SPF and DKIM authentication.
Flexible Control
Site - specific email addresses can be used for better brand consistency, or notification emails can be configured to meet the requirements of particular domain forwarding servers.
Usage
Single Sites
For most single - site configurations, the
MAIL_ENVELOP_FROM
constant can be defined inwp-config.php
as follows:Multisite Configurations
This setup allows you to handle different sender addresses based on the site or subdomain.
Impact
This change enables more flexible management of the sender email address, making it easier to improve email delivery reliability and SPF / DKIM authentication success rates.This is particularly useful for multisite or complex email environments, as it helps address challenges with sender configuration.