Changing the From Name & Email for Transactional Notifications

Updated

Due to a restriction in the WordPress wp_mail() function, it is not possible to change some of the header information for transactional notifications. This includes the ‘From’ name and email address, and ‘CC’ and ‘BCC’ details. In order to get around this you may need to use a function (see below) to change the default name and email address of your outgoing notifications. Please be aware though, that by doing this, you will most likely globally affect all email notifications that WordPress sends out, including those from WordPress, BNFW, and other plugins. Please test appropriately before adding the below code to your website.

To change the default From name and email address in WordPress, paste this code in your functions.php file and change the relevant information.

[cc lang=”php”]

// Change Default Email Address
function bnfw_change_email_address($email) {
return “email@yourdomain.com”;
}
add_filter(‘wp_mail_from’, ‘bnfw_change_email_address’);

[/cc]

[cc lang=”php”]

// Change Default Email ‘From’ Name
function bnfw_change_email_from($from_name) {
return “Your Name”;
}
add_filter(‘wp_mail_from_name’, ‘bnfw_change_email_from’);

[/cc]

It is also worth noting that in order to reduce the chances of your server flagging your notifications as SPAM, you should always ensure that the domain in your ‘From’ email address is the same domain or sub-domain that your website is sending the email out from.