Title: WordPress sends email using apache username
Last modified: September 14, 2021

---

# WordPress sends email using apache username

 *  Resolved [guarnif](https://wordpress.org/support/users/guarnif/)
 * (@guarnif)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/wordpress-sends-email-using-apache-username/)
 * Description
    Wordpress sends emails using the apache username, that is [www-data@domain.com](https://wordpress.org/support/topic/wordpress-sends-email-using-apache-username/www-data@domain.com?output_format=md)
   and I do not find any way to change the username of the email from www-data to
   admin. Any help is very appreciated!
 * Steps taken
    1) I have installed ssmtp to take care of sending email and configured
   it properly (it sends email with the root name as freely specified in the config
   file).
 * 2) I tried to add the following lines in the functions.php of my current theme:
 *     ```
       // Function to change email address
       function wpb_sender_email( $original_email_address ) {
           return 'admin@domain.com';
       }
   
       // Function to change sender name
       function wpb_sender_name( $original_email_from ) {
           return 'Admin';
       }
   
       // Hooking up our functions to WordPress filters 
       add_filter( 'wp_mail_from', 'wpb_sender_email' );
       add_filter( 'wp_mail_from_name', 'wpb_sender_name' );
       ```
   
 * But I still receive emails from [www-data@domain.com](https://wordpress.org/support/topic/wordpress-sends-email-using-apache-username/www-data@domain.com?output_format=md).
 * So I do not know where should I set the username and avoid using the apache username.

Viewing 6 replies - 1 through 6 (of 6 total)

 *  [Alan Fuller](https://wordpress.org/support/users/alanfuller/)
 * (@alanfuller)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/wordpress-sends-email-using-apache-username/#post-14872481)
 * Is this your own server?
 * The steps you have taken, should work, so I suspect a server level issue.
 *  Thread Starter [guarnif](https://wordpress.org/support/users/guarnif/)
 * (@guarnif)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/wordpress-sends-email-using-apache-username/#post-14873436)
 * Hi Alan,
 * yes it is our cloud server. I tried to send emails with ssmtp (this is what we
   use) and it changes the username accordingly, so it looks like wordpress (or 
   php mail) is not giving any username and ssmtp is using the username. But I dont
   understand where to set the email username in wordpress (without using a plugin)
   or php.
 *  [Alan Fuller](https://wordpress.org/support/users/alanfuller/)
 * (@alanfuller)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/wordpress-sends-email-using-apache-username/#post-14873543)
 * OK your code looks good to set sender.
 * WordPress however doesn’t set envelope sender, which isn’t normally an issue 
   as the mail server normally does, but not all and that can cause problems.
 * This COULD be the issue.
 * One way to check, I know you don’t want to install a plugin, but this plugin 
   I wrote initially to solve that on my own host. [https://wordpress.org/plugins/stop-wp-emails-going-to-spam/](https://wordpress.org/plugins/stop-wp-emails-going-to-spam/)
 * As you don’t want a plugin, long term, if it works, I can tell you the code snippet,
   or you can look at the plugin code.
 *  Thread Starter [guarnif](https://wordpress.org/support/users/guarnif/)
 * (@guarnif)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/wordpress-sends-email-using-apache-username/#post-14879393)
 * No, it did not solve it. So I guess it is not passed properly either on php or
   on ssmtp side.
 *  Thread Starter [guarnif](https://wordpress.org/support/users/guarnif/)
 * (@guarnif)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/wordpress-sends-email-using-apache-username/#post-14879565)
 * Found the problem – server side! It was this line FromLineOverride=NO
 *  [Alan Fuller](https://wordpress.org/support/users/alanfuller/)
 * (@alanfuller)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/wordpress-sends-email-using-apache-username/#post-14879570)
 * Great you found it.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘WordPress sends email using apache username’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 6 replies
 * 2 participants
 * Last reply from: [Alan Fuller](https://wordpress.org/support/users/alanfuller/)
 * Last activity: [4 years, 9 months ago](https://wordpress.org/support/topic/wordpress-sends-email-using-apache-username/#post-14879570)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
