How to change WordPress default email From name and address

We have noticed, that every time user submitted a comment on your blog, signed up as a user or did anything that required WordPress to generate and send an e-mail, by default the “From Name” in that message appeared as “WordPress” and “From” address was “wordpress@your-domain.com”.

If this is not the way we want it – there is an easy way of customizing both these fields.

So how can you change these WordPress default email settings for FromName and From address.

So far I found Two ways of doing it:

  1. edit pluggable.php file, look for lines 372-396, and make changes in:      $from_name = ‘WordPress’;
    change ‘WordPress’ to ‘your name or your website’ Like  $from_name = ‘Webtechsource’;$from_email = ‘wordpress@’ . $sitename;
    change ‘wordpress@’ to ‘your name@’ Like $from_email = ‘admin@’ . $sitename;
  2. add filter to functions.php file First of all you need to find and open functions.php file – it should be in your template folder.add_filter(‘wp_mail_from’, ‘new_mail_from’);
    add_filter(‘wp_mail_from_name’, ‘new_mail_from_name’);function new_mail_from($old) {
    return ‘admin@webtechsource.com’;   //return ‘your email address’;
    }
    function new_mail_from_name($old) {
    return ‘Webtechsource Admin’; // return ‘your name or your website’;
    }

These filters will simply override default WordPress email settings.

if you want to remove site name from subject in your email address that is also possible just put this code in your function.php file

//remove sitename from email subject
add_filter(‘wp_mail’, ’email_subject_remove_sitename’);
function email_subject_remove_sitename($email) {
$blogname = wp_specialchars_decode(get_option(‘blogname’), ENT_QUOTES);
$email[‘subject’] = str_replace(“[“.$blogname.”] – “, “”, $email[‘subject’]);
$email[‘subject’] = str_replace(“[“.$blogname.”]”, “”, $email[‘subject’]);
return $email;
}

if you want to read about session in php click here.

I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face – we are here to solve your problems.

I, Dayanand Saini,the founder and chief editor of www.webtechsource.com,have been working as a software engineer from last 4+ years. It's my hobby to learn new things and implement on live environment.

Leave a Reply

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

91 − 87 =

%d bloggers like this: