• Resolved guarnif

    (@guarnif)


    Description
    Wordpress sends emails using the apache username, that is www-data@domain.com 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.

    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)
  • Is this your own server?

    The steps you have taken, should work, so I suspect a server level issue.

    Thread Starter guarnif

    (@guarnif)

    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.

    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/

    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

    (@guarnif)

    No, it did not solve it. So I guess it is not passed properly either on php or on ssmtp side.

    Thread Starter guarnif

    (@guarnif)

    Found the problem – server side! It was this line FromLineOverride=NO

    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.