By default, every email WordPress sends, password resets, new user notifications, comment alerts, WooCommerce order confirmations, comes from wordpress@yourdomain.com with the sender name “WordPress”. Neither of these is ideal. The generic sender name makes your emails look unbranded and reduces trust, and the wordpress@ address may not exist as a real mailbox, which can cause deliverability problems with some mail servers and spam filters that verify the sender address.
This snippet overrides both values globally with two simple filters, affecting every email sent through WordPress’s wp_mail() function.
The Code
Add this to your functions.php or a site-specific plugin. Replace the email address and name in the callbacks with your own values. The change takes effect immediately for all outgoing mail.
Choosing the Right From Address
The from address should be on the same domain as your site. Sending from a domain that doesn’t match your site’s domain, or from a free email provider like Gmail, significantly increases the likelihood of your emails landing in spam. Most mail servers perform reverse DNS lookups and SPF/DKIM checks against the sender domain, and a mismatch is a red flag.
Use an address that either has a real mailbox behind it or is properly configured to reject bounces gracefully. A no-reply@yourdomain.com address is common for transactional email, but make sure your DNS records (SPF, DKIM) are configured to authorise your sending server for that domain. If you’re routing WordPress email through an SMTP plugin like Postmark, those records are set up as part of the Postmark domain verification process.
Why This Alone May Not Be Enough
Changing the from name and email address improves branding and can help with basic deliverability, but it doesn’t fix the underlying problem that WordPress sends email through PHP’s mail() function by default. Mail sent via mail() from shared hosting or a web server is routinely flagged as spam because web servers aren’t optimised as mail relays and often lack proper SPF/DKIM/DMARC configuration.
For reliable email delivery, pair this snippet with an SMTP plugin (FluentSMTP, WP Mail SMTP) or a dedicated transactional email service. Postmark, Mailgun, SendGrid, and Amazon SES all provide WordPress integrations and handle authentication, bounce tracking, and deliverability monitoring. The from address filter in this snippet remains relevant even when using those services, it sets the human-facing sender name and address that appears in the recipient’s inbox.
Plugin-Specific Overrides
Some plugins, WooCommerce, for example, set their own from name and email for the emails they send, bypassing the global filters. In those cases, you’ll need to configure the from details within the plugin’s own settings panel rather than relying solely on this snippet. The snippet handles all emails sent directly through wp_mail() without a plugin-level override.
add_filter( 'wp_mail_from', function( $email ) {
return 'hello@nahnuplugins.com';
} );
add_filter( 'wp_mail_from_name', function( $name ) {
return 'Nahnu Plugins';
} );
