The MU forums have moved to WordPress.org

How to set email address for mail to users? (36 posts)

  1. modifiedcontent
    Member
    Posted 16 years ago #

    When a user signs up for a blog on my system they receive an email from "myusername@box142.hosting.com".

    How can I replace that with name@mywebsite.com?

    I contacted my hosting company and received this unhelpfull reply:

    You will need to modify the script (usually a configuration script) so that it uses your e-mail address sends the e-mail from myname@mywebsite.com

    So which script should I modify how?

  2. andrea_r
    Moderator
    Posted 16 years ago #

    When you set up MU, did you use the myusername@box142.hosting.com email address? If so, just go into the database and change it.

  3. drmike
    Member
    Posted 16 years ago #

    Actually we just covered this a few days ago here in the forums.

    Donncha, if you're reading this, can we *PLEASE* have a search box here like we do over in WP.com land. The search bar we do have does not work as it goes over to WP.org.

    Anyway...

    Here's the thread.

    Hope this helps,
    -drmike

  4. modifiedcontent
    Member
    Posted 16 years ago #

    Thanks for the suggestion andrea_r, but no, I didn't use myusername@box142.hosting.com. It's some kind of default system e-mail address that is supposed to be replaced with/translated into (?) my public e-mail address.

    The solution in the thread drmike suggested (thanks!):

    You want to find

    $message_headers = 'From: ' . $title . ' <support@' . $_SERVER[ 'SERVER_NAME' ] . '>';

    (It's near the bottom)

    and simply change it to

    $message_headers = 'From: ' . $title . ' <noreply@' . $_SERVER[ 'SERVER_NAME' ] . '>';

    Apparently the "$_SERVER[ 'SERVER_NAME' ]" bit on my host's server just produces the generic "@box142.hosting.com" address, instead of the "@mywebsite.com" address I want. (That's probably the difference between dedicated server vs shared server...)

    How can I edit the code to force it to use "name@mywebsite.com" without messing up the system? Can I simply do this?:

    $message_headers = 'From: ' . $title . ' <noreply@mywebsite.com>';

    Or can the code be tweaked to make it more friendly to shared server situations? "$_DOMAIN[ 'DOMAIN_NAME' ]" or something like that...?

    I had done a search for solutions to this problem on the different Wordpress forums, but couldn't find anything. I had trouble coming up with effective keywords; email + address + ???

  5. donncha
    Key Master
    Posted 16 years ago #

    drmike - Sorry, I've asked Matt several times to update the search box. I'll drop him a mail and ask him again!

  6. drmike
    Member
    Posted 16 years ago #

    Donncha, thanks. It's hard for me at least because I'm not allowed to make any bookmarks depending on where I am and, when at least I have to search, I have to go digging for the search page.

    Going back to the question though, wouldn't using HOSTNAME be better?

    The issue though that I see is where WPMU grabs the sending email address for sending other emails like notices of trackbacks. I think MU should just be grabbing it out of the blog's admin profile myself. That way, it would be blog specific.

    Granted, it may already do this elsewhere...

  7. modifiedcontent
    Member
    Posted 16 years ago #

    I've replaced all the <support@' . $_SERVER[ 'SERVER_NAME' ] . '> lines with <name@mywebsite.com>.

    When I signed up for a test blog with a silly blog name I received a confirmation from 'My Silly Blogname'. The return address is name@mywebsite.com as it should be.

    That's a suprising result and not necessarily bad, but I would prefer to have 'My Web Site' in the From line.

    How would drmike's 'using HOSTNAME' solution work? Like this?

    $message_headers = 'From: ' . $title . ' <noreply@' . $_HOST[ 'HOST_NAME' ] . '>';

  8. drmike
    Member
    Posted 16 years ago #

    Actually it would be $_SERVER[ 'HOST_NAME' ] but I still would rather use the domain out of the database. I'm sure it's defined somewhere.

  9. mickemus
    Member
    Posted 16 years ago #

    How about creating an account on your mailserver and using the SMTP if your site host is not so helpful?

    Just a suggestion :)

  10. drmike
    Member
    Posted 16 years ago #

    WPMU doesn't use it though. WPMU uses the PHPmailer to send out these emails. An email account would be moot.

  11. modifiedcontent
    Member
    Posted 16 years ago #

    When I use $_SERVER[ 'HOST_NAME' ] I just get the same ugly "myusername@box142.hosting.com" result again... :-(

    Best option for me so far is replacing everything with <name@mywebsite.com>, but there may be downsides to that?

    And I don't understand why it then uses the blog name in the 'From' line or how to replace it with 'My Web Site'.

  12. modifiedcontent
    Member
    Posted 16 years ago #

    I've reinstalled Wordpress MU with the very latest nightly build. The confirmation email was still sent from myusername@box142.bluehost.com

    I know I'm supposed to report a whole list of details about the server setup if this is a bug. I'm not sure yet whether it's a Wordpress bug or whether I should blame Bluehost. Anyway, it's not my server, so I can't control their settings. But Bluehost is one of the bigger hosting companies in the US so I would expect Wordpress MU to work.

    Am I the only one who has this problem?

    BTW, the other thread that drmike linked to is about a similar, but ultimately unrelated issue. It provides a solution of kinds, but it's not the same problem.

  13. drmike
    Member
    Posted 16 years ago #

    Why not just simple go through the /wp-includes/wpmu-functions.php file and replace it with the address you want in there? That's what is suggested up above.

    But Bluehost is one of the bigger hosting companies in the US so I would expect Wordpress to work.

    This is not WordPress, it's WordPress Multiuser. Sounds silly but you're going to be telling folks that many times every day. You might want to learn the difference now so you can explain it to others. I get to say it a lot in the WP.com forums when folks expect to have complete control over their blogs.

    WPMU runs a lot different than how WP does.

  14. modifiedcontent
    Member
    Posted 16 years ago #

    Why not just simple go through the /wp-includes/wpmu-functions.php file and replace it with the address you want in there? That's what is suggested up above.

    I've already done that last time. That got me to this point:

    http://mu.wordpress.org/forums/topic.php?id=1630&replies=25

    Following andrea_r's suggestion in that thread I've reinstalled the whole thing with the latest nightly build, but there's no change.

    This is not WordPress, it's WordPress Multiuser.

    Point taken. I've edited my previous post accordingly.

    Where's trac?

    Here some incomplete answers to the bug tracking questions:

    * Is VHOST true or false

    don't know, have to study on it

    * Is the path to your WordPress? MU install "/" or some directory?

    No, it at the root of my account, but not at the root of Bluehost's server.

    * Anything in the error logs? If you didn't get a welcome email, check your mail logs.

    There's no error in this case, just unwelcome behavior.

    * Does the information in wp_blogs, wp_users and wp_site match your blog, user and site?

    don't understand the question. Match in what respect?

    * Mention the version number, SVN check-in number or the date you downloaded the snapshot.

    What snapshot?

    Other things to do:

    * Read the README.txt file. There are important instructions there on how to configure your web server.

    I've read it!

    * Check the following: wp-config for $base, database tables wp_blogs and wp_site match the URL you're using.

    Don't understand the question, but doesn't seem relevant to the email address problem

    * If your new install doesn't work, you should debug wpmu-settings.php to figure out where it's going wrong. Use print, print_r and error_log to dump variables, especially $blogname.

    My install does work. The system is just using the wrong e-mail address.

    * If it did work, and then it broke, what did you do last?

    It's a consistent problem that appears after a fresh reinstall with the latest nightly build.

    * Check if your bug hasn't been already fixed:

    Checked for as far possible

    * Search closed tickets to see if your bug was reported and fixed.

    Checked

    * Check the forums at http://mu.wordpress.org/forums/ for relevant threads.

    Checked. Posting on one now.

  15. modifiedcontent
    Member
    Posted 16 years ago #

    Question put another way:

    Is there a way to set one fixed email address for all the mail that's send out from the system?

  16. andrea_r
    Moderator
    Posted 16 years ago #

    " * Is VHOST true or false

    don't know, have to study on it"

    All this means is do you have subdomains set up or directories? IE; is you setup username.yoursite.com or yoursite.com/username/?

    " * Check the following: wp-config for $base, database tables wp_blogs and wp_site match the URL you're using.

    Don't understand the question, but doesn't seem relevant to the email address problem"

    It *is* relevant as these are the fields in the database which would hold information like your emails address - the one you say it keeps sending from.

    In the directions there are (I think) TWO files in which you need to change the word BASE to /. It could cause weird issues.

    "My install does work. The system is just using the wrong e-mail address.
    It's a consistent problem that appears after a fresh reinstall with the latest nightly build."

    Then the problem is something with your server setup. By asking all these seemingly pointless questions, drmike is trying to help you narrow down where to look.

    Also, since you're new here, I'll point out that not one of us regulars on the forum are developers on this project, nor are any of us paid to be here, nor are there any moderators. We're users just like you and we devote our time because we believe in the bigger cause of open source projects.

  17. modifiedcontent
    Member
    Posted 16 years ago #

    Then the problem is something with your server setup. ... It *is* relevant as these are the fields in the database which would hold information like your emails address - the one you say it keeps sending from.

    The myusername@box142.bluehost.com is NOT in my WPMU database. It's the system's e-mail address associated with my hosting contract that my public e-mail addresses are somehow derived from.

    Apparently there is a bit of code in WPMU that calls the base system e-mail, which is probably fine if you have your own server, but not if you're on a shared hosting service.

    I have already asked my hosting and they replied:

    You will need to modify the script (usually a configuration script) so that it uses your e-mail address sends the e-mail from myname@mywebsite.com

    That was my original question. How can I modify the script to force it to use the admin e-mail address in the WPMU database instead of that base system e-mail address? Where's that bit of code that calls the e-mail address?

    drmike sent me to another thread that was somewhat related. That solution apparently didn't go to the core of the problem, because validation e-mails get sent out from the user's own blog name instead of the main website's name.

    By then I also had problems in my activation process that may or may not have been created by my earlier changes in the code.

    So I installed everything again with the latest build and the whole thing starts over again...

  18. andrea_r
    Moderator
    Posted 16 years ago #

    I'm on a shared system as well.

    If the wrong email address is not in the database, then WP has no idea about the myusername@box142.bluehost.com address. It can't guess it. It pulls that email address *out of the databse*. Somewhere along the line *your host* is changing the right email address into the wrong one.

    Many hosts are very quick to point out the "it must be your script" line when they are unfamiliar with it. Looks better for them than "I don't know".

    "because validation e-mails get sent out from the user's own blog name instead of the main website's name."

    I double checked this on my own setup. The email has the username attached to it, but the actual email address is from my admin account - just like it is supposed to be.

  19. modifiedcontent
    Member
    Posted 16 years ago #

    I double checked this on my own setup. The email has the username attached to it, but the actual email address is from my admin account - just like it is supposed to be.

    After the edits suggested in the other thread I have that result, which is pretty close to where I want it to be.

    But I don't want the user's blog name in the From line of e-mails that are sent out, even though the actual address is still the admin's. In my case members should get e-mails from "the company" they signed up with, not from their own blogs.

    Any way to change that with a line of code?

    It can't guess it. It pulls that email address *out of the databse*. Somewhere along the line *your host* is changing the right email address into the wrong one.

    I've sent Bluehost another e-mail with a link to this thread.

  20. modifiedcontent
    Member
    Posted 16 years ago #

    Bluehost now sent this reply:

    In the admin area of wordpress you can modify the e-mail address you want to be sending e-mail from. You can set this up in the configuration settings of wordpress.

    I only see one place in the Wordpress admin area where I can set an e-mail address and that's in wp-admin > Options > General > E-mail address.

    That has always been set to the e-mail address I want, but the system still uses that base system e-mail address username@box142.bluehost.com.

    ?! :-(

  21. andrea_r
    Moderator
    Posted 16 years ago #

    You have to tell them, and stress emphatically, that you are NOT using the regular Wordpress - you are using WP MultiUser. It's *different*.

    Just for giggles, if you had a regular WP install in the same space, would/does it send emails form the wrong one?

  22. modifiedcontent
    Member
    Posted 16 years ago #

    Bluehost now sent me this solution. I've tried the 'Alternative for PHP Users', without any effect. This solution implies the 'From:' header in WPMU is not formatted properly:

    Problem
    Why do e-mails from my webpage come from < username > @ < box > .bluehost.com when I have specified otherwise?

    Solution
    This is because our servers require you (or your script) to use a properly formatted, valid From: header in your email. If the From: header is not formatted correctly, empty or invalid our system will change the from address to be <username>@<box>.bluehost.com. To stop this, you must change the script you are using to correctly use a valid From header.

    Examples of headers that should work would be:
    From: user@domain.com
    From: <user@domain.com>
    From: "name" <user@domain.com>

    Examples of headers that will NOT work:
    From: "user@domain.com"
    From: user @ domain.com

    Alternative for PHP Users:
    - You can also modify which account should be used when sending out using the mail() function. Inside the local php.ini file, you will find a line of code that looks something like this(around line 319):

    sendmail_from = mail@yourdomain.com

    Be sure to uncomment this by deleting the ';' before the directive. Also, the account you use must be a valid created account.

  23. andrea_r
    Moderator
    Posted 16 years ago #

    So do you have a php.ini file soemwhere in your account? It says right up there they have it commented out and to uncomment it so it will stop sending it from the wrong address.

  24. drmike
    Member
    Posted 16 years ago #

    myusername@box142.bluehost.com is coming from the box's hostname. The function file is pulling the information out of the way the box is set up. (I'm on a locked down terminal. I can't give you specific details I'm afraid.)

    If you give me the address you would like these emails to come from, I can post a wpmu-functions.php file for you to use with the email address.

  25. modifiedcontent
    Member
    Posted 16 years ago #

    If you give me the address you would like these emails to come from, I can post a wpmu-functions.php file for you to use with the email address.

    Thanks! Obviously I'm reluctant to post the email address here. Let's say info@mywebsite.com. Can you give a generic solution?

    myusername@box142.bluehost.com is coming from the box's hostname. The function file is pulling the information out of the way the box is set up.

    Yes. I'm trying to figure out what code to edit to change that behavior, either in the WPMU code or on my server.

    So do you have a php.ini file soemwhere in your account? It says right up there they have it commented out and to uncomment it so it will stop sending it from the wrong address.

    I've tried that, variations of it, but it had zero effect.

  26. andrea_r
    Moderator
    Posted 16 years ago #

    You're in drmike's hands now. :)

  27. modifiedcontent
    Member
    Posted 16 years ago #

    If you give me the address you would like these emails to come from, I can post a wpmu-functions.php file for you to use with the email address.

    I had already tried this solution with partial success, but possibly with side effects... I don't know. That's why I tried a fresh reinstall hoping that the problems would disappear.

    If you know another solution, please let me know. Thanks!

  28. gwagenknecht
    Member
    Posted 16 years ago #

  29. Simon1
    Member
    Posted 16 years ago #

    I have wpmu-functions.php edited to have system mails sent in the format:

    mail($user->user_email, $subject, $message, $from, $ffrom);

    Where $from and $ffrom are something like:

    $from = 'From:Site Name?admin@sitename.com?';
    $ffrom = '-fadmin@sitename.com';

    NB: the ?? = < and >

    Has anyone else found that using the default wp_mail() sometimes results in the mails not being sent, whereas (for me at least) using mail() leads to more consistent results?

    I think WPMU needs an smtp option by default, as i still have trouble using sendmail becaue of blacklisting when using a shared hosting company. I tried adapting wp-phpmailer for that purpose, but couldn't get it working.

  30. drmike
    Member
    Posted 16 years ago #

    Has anyone else found that using the default wp_mail() sometimes results in the mails not being sent, whereas (for me at least) using mail() leads to more consistent results?

    First thing I would do is look in the mail server's error logs. You're running server software now. You need to be thinking like a system admin.

    I think WPMU needs an smtp option by default, as i still have trouble using sendmail becaue of blacklisting using a shared hosting company.

    WPMU works fine on a shared account. Many of us (including me) are using it in such an environment without issue. Not sure what you mean by blacklisting.

About this Topic

  • Started 16 years ago by modifiedcontent
  • Latest reply from andrea_r