Vijayan
Vijayan Thanks for stopping by guys! I'm Vijayan and Techpulse is my beloved brainchild. Currently working as a PHP developer in a digital marketing start-up, I'm overly passionate about not just learning new things but also putting those into practice. I swear by a quote I once came across... 'What separates successful people from unsuccessful people is the former's ability to execute'. Feel free to reach out to me if you have any questions, suggestions or feedback. Hoping to see more of you here!

How to Change wp_mail_from and wp_mail_from_name WordPress


How to Change wp_mail_from and wp_mail_from_name WordPress

The wp_mail_from (an email address) filter modifies the “from email address” used in an email sent using the wp_mail function. When used together with the wp_mail_from_name (the real name given to the email address) filter, it creates a from address like “TechPulseToday info@techpulsetoday.com”. The filter should return an email address. Just adding this below code to functions.php of your WordPress theme will change the from address in your WordPress theme or You don’t even need to mess with a file editor and FTP for this. I would simply go to the Appearance > Editor menu in the WP Admin Panel, then find ‘functions.php’ in the list of theme files on the right. Add these filters and you are in business. Two Important notes,

  1. Make sure the email is from the same domain
  2. As your website to avoid being marked as spam.

wp_mail_from

1
2
3
4
5
6
// wp_mail_from
add_filter('wp_mail_from', 'from_mail');

function from_mail($original_email_address) {
    return 'info@techpulsetoday.com';
}

wp_mail_from_name

1
2
3
4
5
6
// wp_mail_from_name
add_filter('wp_mail_from_name', 'from_mail_name');

function from_mail_name($original_email_address_name) {
    return 'TechPulseToday';
}

comments powered by Disqus