Change Sender Name And Email in Outgoing WordPress Email.

This can be done by many plugins but the real reason behind doing this using custom code is that Using too many plugins can harm your website or blog speed and performance which is not desirable by any site owner. that’s why we use custom code in most of the cases if the issue is not bigger like to change sender email and name is outgoing WordPress email.

By default, when we sends an email notification it uses ‘WordPress’ as the sender name. This looks unprofessional and we can change it to a real person or your website title.

So to add custom code, first move to your WordPress theme function.php and use two wordpress hook.

  • 'wp_mail_from'
  • 'wp_mail_from_name'

We can easily change that by adding this code to our theme’s functions file.

// Function to change email address
function ChangeSenderEmail( $email ) {
    return 'abc@example.com';
}
add_filter( 'wp_mail_from', 'ChangeSenderEmail' );


// Function to change sender name
function ChangeSenderEmailName( $name) {
     return 'Xyz Scott';
}
add_filter( 'wp_mail_from_name', 'ChangeSenderEmailName' );

Enjoy

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top