How to Change WordPress Email From Sender Name Email Settings Without Plugin

How to Change WordPress Email From Sender Name Email Settings Without Plugin

Do you know best things about WordPress not only CMS but it is an application framework, it comes with a huge selection of utility functions that make it easy to handle form helpers, validation, file structures, email encoding and much more.

We can easily customize existing actions and filters with WordPress which allows you to override the core WordPress functions with any code you want. The pluggable functions can be included in the functions.php file or in your own plugins to produce new functionality for the functions already used in WordPress.

In this tutorial, we are going to show you how to Change WordPress Email “Send From” Settings. By default, your WordPress installation sends user registration emails from “wordpress@domainname.com” For example, if your blog is at site.domainname.com, emails will come from wordpress@domainname.com.

Change the from email address in WordPress

Here are snippets for changing the “from email address” in WordPress just copy below code and past into theme function.php file:

function phpkida_filter_wp_mail_from($email){
    return "contact@phpkida.com";
}
add_filter("wp_mail_from", "phpkida_filter_wp_mail_from");

Change the email from name in WordPress

Here’s the snippet for changing the “from email name” in WordPress just copy below code and past into theme function.php file:

function phpkida_filter_wp_mail_from_name($name){
    return "PHPkida Team";
}
add_filter("wp_mail_from_name", "phpkida_filter_wp_mail_from_name");

Change the password reset mail title in wordpress

function my_retrieve_password_subject_filter($old_subject) {
    // $old_subject is the default subject line created by WordPress.
    // (You don't have to use it.)

    $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
    $subject = sprintf( __('[%s] Password Reset'), $blogname );
    // This is how WordPress creates the subject line. It looks like this:
    // [Doug's blog] Password Reset
    // You can change this to fit your own needs.

    // You have to return your new subject line:
    return $subject;
}

Change the password reset mail message in wordpress

function my_retrieve_password_message_filter($old_message, $key) {
    // $old_message is the default message already created by WordPress.
    // (You don't have to use it.)
    // $key is the password-like token that allows the user to get 
    // a new password

    $message = __('Someone has asked to reset the password for the following site and username.') . "\r\n\r\n";
    $message .= network_site_url() . "\r\n\r\n";
    $message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n";
    $message .= __('To reset your password visit the following address, otherwise just ignore this email and nothing will happen.') . "\r\n\r\n";
    $message .= network_site_url("wp-login.php?action=rp&key=$key&login=" . rawurlencode($user_login), 'login') . "\r\n";

    // This is how WordPress creates the message. 
    // You can change this to meet your own needs.

    // You have to return your new message:
    return $message;
}

// To get these filters up and running:
add_filter ( 'retrieve_password_title', 'my_retrieve_password_subject_filter', 10, 1 );
add_filter ( 'retrieve_password_message', 'my_retrieve_password_message_filter', 10, 2 );
About Author

My name is Mukesh Jakhar and I am a Web Application Developer and Software Developer, currently living in Jaipur, India. I have a Master of Computer Application in Computer Science from JNU Jaipur University. I loves to write on technology and programming topics. Apart from this, I love to travel and enjoy the beauty of nature.

Sign up for weekly update

Milkshake is almost ready. If you're interested in testing it out, then sign up below to get exclusive access.