When sending emails from my WordPress install, my 'from address' includes a www.

Currently, it's sending email from web@www.domain.com when what I want is web@domain.com.

However, if I change the domain name - lets say to abc.com - it works properly.

I tried to add some code to my theme's functions.php to force a rewrite of the domain name, but I'm still getting the same result.

Has anyone experienced something like this?


You can change the email address with the wp_mail_from filter:

add_filter( 'wp_mail_from', function() { return 'web@example.com'; } );
  • I did this before in my function, but still not working. This problem only appeared for the specific domain. Like I said before, if use domain.com email address always using www and the other hand if I changed used abc.com or other domain name from functions will works well. – da_root Jun 10 '16 at 3:45
  • There's something else causing the email address to change, then. If the headers are already set, wp_mail will use them; if not, then it uses wordpress@$sitename after it strips 'www.' from $sitename. Check your installed plugins to see if any of them are defining their own wp_mail function that doesn't use the same core filters to modify the address. – Morgan Estes Jun 10 '16 at 4:02
  • Had to disabled plugins, and also switch back onto default theme still no luck. This only happened for a one domain (in my example if used domain.com). Is it possible cause by the server configuration or NS pointing? My server running under Linux Ubuntu VPS – da_root Jun 10 '16 at 4:09
  • 1
    Since WordPress doesn't send email from 'web@www.domain.com' on its own, then I'm going to guess it's outside of the WP install that this is happening. – Morgan Estes Jun 10 '16 at 4:15
  • Mmmm...do you mean is cause by server or NS or something else. Ok, I think I need to go to discuss with hosting guy. Thanks for the comment – da_root Jun 10 '16 at 4:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.