How to set from email address in WordPress

To set from email address for all outgoing emails on your WordPress site, you can use the ‘wp_mail_from‘ filter. You can add the following code to your theme’s functions.php file or create a custom plugin to ensure that all emails sent from your WordPress site use the specified email address:

function set_wp_mail_from($email) {
return '[email protected]'; // add your email address here
}
add_filter('wp_mail_from', 'set_wp_mail_from');

function set_wp_mail_from_name($name) {
return 'Your Site Name'; // You can set this to any name you want
}
add_filter('wp_mail_from_name', 'set_wp_mail_from_name');

This code does two things:

  1. Sets the “From” email address to “[email protected]
  2. Optionally, sets the “From” name to Your Site Name. You can change this to any name you prefer or remove the set_wp_mail_from_name function if you don’t need to change the name.

After adding this code, all emails sent from your WordPress site should use the email address [email protected]