WordPress.org

Ready to get started?Download WordPress

Forums

How does WP send the user registration email? (58 posts)

  1. MailGuard
    Member
    Posted 9 years ago #

    WP isn't sending emails (although it says it is) when I create test users to inform them of the password. My mailbox is empty but WP doesn't complain about not being able to send it. As my box has the minimum services running, is there a requirement for WP to use sendmail or exim or does it handle contacting the remote smpt server itself?

    Please help!

    Thanks.

  2. o2slim
    Member
    Posted 9 years ago #

    Having the same problem. I'm not sure how WP is getting logon info for any mail server etc to send an email. The problem may also be that my hosting company, although providing me with my own domain http://www.mydomain.com web address it does not for e-mail servers, my e-mail server is mail.hostingcompany.com :(

  3. lyklev
    Member
    Posted 9 years ago #

    WordPress uses the mail function built in php itself. So it does pretty much nothing except relying on underlying system. It does not do any authentication.

    This also means that your hosting provider must have the sendmail function in php activated; it is possible that they closed that.

    Another possibility is that your isp blocks mails from domains where e-mail has a different domain, to prevent spam.

  4. upt1me
    Member
    Posted 9 years ago #

    I'm having the same problem. My notifications on comments posts are being sent (same domain to same domain), but user registration doesn't produce any email even when I sign a test user up with a valid email address on the same domain.

  5. Nick Momrik
    Member
    Posted 9 years ago #

    Are you sure WP is supposed to email this?

  6. MailGuard
    Member
    Posted 9 years ago #

    Is there a config file for hostname, username, password, etc?

  7. MailGuard
    Member
    Posted 9 years ago #

    Since I am running this on my own box, how can I confirm it works? I have looked and don't see any hits on my firewall so that isn't blocking it. WP says it sends it, I don't see any traffic or any entries in the message or syslog about errors. Where is it going? Help!

  8. Tahongawaka
    Member
    Posted 9 years ago #

    The php mail function uses sendmail on the host machine. No account information is needed. The first thing you need to know is if you're using a winblows machine or a *nix machine. If you're using *nix, you should be ready to go. For Winblows, you may need a sendmail emulator, like http://glob.com.au/sendmail/

    Also, create a phpinfo() page and check that the path to sendmail is correct.

    To check to see if it is functioning correctly, log out and register yourself with an email address on the same machine. Then, log out and register yourself with an email address on a different machine. No emails? Something else is wrong. Of course, someone else at mydomain.com has the same issue: http://forum.mydomain.com/viewtopic.php?t=5440&highlight=php+mail

    If you find that it really doesn't work, it could be that the admins of the server have blocked mail() from working. If that's the case, I found a replacement function for it, and have it at http://www.netfobs.org/n_mail.phps . You'll need to copy it and add the function to the end of wp-includes/functions-compat.php. Change the From email address on line 6. Open wp-includes/functions.php and look for @mail on or about line 1610. Change @mail to @n_mail. Because of the way they work, n_mail() isn't quite as robust as the mail() function and some of the headers might not make it through.

    I haven't tried this because my sendmail works correctly (and my host is 5 cents more per month). Your mileage may vary. Back up your files before you make any changes. I'm not going to be held responsible if you break something.

  9. Christo
    Member
    Posted 9 years ago #

    I'm in the same situation as upt1me however I'm sending update notification to a seperate domain and it also works fine. Regarding the last post why would the mail() issue not effect the posting notifications?

  10. Ryan Boren
    WordPress Dev
    Posted 9 years ago #

    First, you may be running into this bug. Try this fix and see if that helps.

    Some hosts block outgoing emails that don't contain an email address that exists on that host in the From: and/or To: fields. This situation is described in this bug. Comment posts going back to a valid username on your domain would work because they have a To: field that is valid for your host. Registration notifications going to another host will have neither a valid From: nor a valid To: field and your host won't send the email.

    Below is a possible fix for the registration notifications. I puts the admin email address in the From: field. This assumes that the admin email address is a valid username on the machine hosting your wordpress installation.

    --- wp-includes/functions.php (revision 2386)
    +++ wp-includes/functions.php (working copy)
    @@ -1598,6 +1598,7 @@
    function wp_mail($to, $subject, $message, $headers = '') {
    if( $headers == '' ) {
    $headers = "MIME-Version: 1.0n" .
    + "From: " . get_settings('admin_email') . "n";
    "Content-Type: text/plain; charset=\"" . get_settings('blog_charset') . "\"n";
    }

    So, find the wp_mail() function in functions.php and add that from line to $headers.

  11. Ryan Boren
    WordPress Dev
    Posted 9 years ago #

    The forum munged the patch a bit. You can get it here.

  12. MailGuard
    Member
    Posted 9 years ago #

    This is wierd, I have tried the @n_mail function and then changed back to the defaults and tried the changes in .diff above and still no dice. This is a box I have here under my own control. I don't see any traffic going out but WP is still saying the use registration was sent.

  13. upt1me
    Member
    Posted 9 years ago #

    I got user registration working had to adapt the functions.php to work within the constraints of my webhost:

    http://mosquito.wordpress.org/view.php?id=980

  14. jpettit
    Member
    Posted 9 years ago #

    I think i'm having this same problem.
    At first i thought it was just Ryan's WP-Comment Form plugin (http://wordpress.org/support/topic.php?id=22318) that wasn't working...but after finding this thread, i tested the WP emailing features, and they too don't work.

    I tried the 2 techniques here. Tahongawaka's hack on @n_mail and the patched functions.php...neither work for me. I know the admin email from phpinfo() and tried changing that too.

    Any other suggestions? or if not, what questions should i submit to my host?
    Thanks.

  15. Tahongawaka
    Member
    Posted 9 years ago #

    Let's see if answering a few different questions will help. Which MTA are you using, is it working, and what does grep apache /var/log/mail.log reply? [change apache to whatever user your web server is running as, and set the path for the mail log correctly] Can you send other email from php?

    Basically, we need to figure out if this is a problem with WordPress, php or your MTA.

  16. jpettit
    Member
    Posted 9 years ago #

    Thanks for the response Tahongawaka.
    I'm going to need a little more guidance on your requests.

    I can tell you according to phpinfo() my MTA is sendmail (path is: /usr/sbin/sendmail -t -i).
    Server info is: Apache/1.3.33 (Unix) PHP/4.3.10 mod_ssl/2.8.22 OpenSSL/0.9.7a FrontPage/5.0.2.2635 mod_throttle/3.1.2
    I don't have command line access to my server so is there a way to run the grep command using a php script or something?
    Is there a way to test if i can send email using php other than using WP?

    I know that i used to get email notifications in WP1.2 (i remember the volume of spam i once got). However, i turned that off, and only just turned it back on with the upgrade to 1.5.
    FYI...i have rolled back the changes mentioned above to 'standard' 1.5 configuration as they provided no change. I can re-implement them if that is required to troubleshoot.
    Thanks for your help.

  17. jpettit
    Member
    Posted 9 years ago #

    I looked more closely at phpinfo() and noticed this entry in PHP Core:

    sendmail_from me@localhost.com me@localhost.com
    sendmail_path /usr/sbin/sendmail -t -i /usr/sbin/sendmail -t -i

    Would the 'me@localhost.com' (it says that exactly...that isn't modified to stop spam) have any bearing on the issues I am having?

    It does specify a valid email address for in PHP Variables:

    _SERVER["SERVER_ADMIN"] webmaster@mydomain.com

  18. jpettit
    Member
    Posted 9 years ago #

    Can someone point me to a very simple PHP file that will send a test message to my mail server so that i can test if it's WP or my host that is giving me problems?
    Thanks.

  19. Tahongawaka
    Member
    Posted 9 years ago #

    http://us4.php.net/manual/en/function.mail.php has some sample scripts. The sendmail_from address shouldn't have any effect on what you're sending, unless you have some spam blocker running on your MTA. Phpinfo won't tell you the MTA, just the path to sendmail. Check to make sure that file really exists. To determine your mta, telnet to the localhost, port 25 and read the banner.

    For a php shell, try http://gimpster.com/php-shell/ (running WordPress).

    If email was working when you had 1.2 a while back, and it's not working now, it is probably an administration thing. When I started with my current web host, the php mail was configured to not allow mail. Then they upgraded and it was all working again. Perhaps you can find some better tech support or move to a different server. Vote with your dollars.

  20. jpettit
    Member
    Posted 9 years ago #

    thanks very much for your help tahongawaka.
    the problem must lie with my host. i have put in a email request to them to get them to look at it.
    using a simple php script, i am able to get a response back from it stating that it sent the email...however i never receive it. i tried multiple ways and configs.
    i also attempted to telnet to my mail server, but i got a 'connection refused by host' or a operation timed out.
    thanks again.

  21. Tahongawaka
    Member
    Posted 9 years ago #

    It appears that there is no MTA on the machine for whatever reason.
    You might try the wp-phpmailer [http://dev.wp-plugins.org/file/wp-phpmailer/trunk/wp-phpmailer.php] and change the configuration to fit how you actually send mail from your account. Hopefully this will work for you and you will have a happy installation again.

  22. pdysko
    Member
    Posted 9 years ago #

    I just changed the header variable to the following in wp_mail in function.php

    '$headers = "From:" . get_settings('admin_email') . "\nX-Mailer: PHP/" . phpversion();'

    I got the idea from http://ca3.php.net/manual/en/function.mail.php

    I'm not sure what the X-Mailer:PHP does, but it fixed it.

    Note that the admin email has to be of the form "my@mydomain.com" otherwise the mail function doesn't work. Most likely restrictions on my web hosting company.

    Note: My admin email in WP 1.5 under Options->General Options was set to something else then "my@mydomain.com", when I changed it and did an update to the options the email change didn't take effect for the admin user.

    You actually have to go to Users->Your Profile and make the email change there instead.

    Hope this helps.

  23. monkeymcgee
    Member
    Posted 9 years ago #

    Thanks pdysko--your solution ended up being the one that worked for me.

    My host allowed the emails, but I wanted the signup notifications to come from my domain instead of the host's domain.

  24. shutdownrunner
    Member
    Posted 9 years ago #

    I'm very thankful to you Tahongawaka. I tried for a few hours to make sendmail work and it took me just 20 minutes to install phpmailer and it works, just works. :)

  25. nodrone
    Member
    Posted 9 years ago #

    Could *someone* develop a plugin that works akin to FreePops: interact with webmail to send wordpress email on servers who do not provide smtp or php mail?

    http://www.freepops.org/en/

  26. al_gorithm
    Member
    Posted 9 years ago #

    I'm having the same problem as the first poster. Here's the story:

    1. Installation successful, I can login as admin. When I create test users and the registration e-mail is supposed to be sent, it never arrives.

    2. Troubleshooting included updating the functions.php file to fix the known issues. A snippet of my functions.php file is below:

    'function wp_mail($to, $subject, $message, $headers = '') {
    if( $headers == '' ) {
    $headers = "MIME-Version: 1.0\n" .
    "From: " . get_settings('admin_email') . "\n" .
    "Content-Type: text/plain; charset=\"" . get_settings('blog_charset') . "\"\n";
    }
    return @mail($to, $subject, $message, $headers);
    }'

    This gets rid of the $more argument, which apparently farts when it tries to execute. And it also references the 'admin_email' on my host, which does exist as admin@mydomain.com. (This was to fix the problem of having a nobody@mydomain.com sending out mail from the php file, which most hosts don't allow)

    And yet, the problem persists.

    So, I ran the test phpmail script on my hosts's site to make sure the default phpmail works, the code for this is below:

    '<?

    require("c:\php\includes\class.phpmailer.php");

    $mail = new PHPMailer();

    $mail->IsSMTP();

    $mail->Host = "mail.brinkster.com";

    $mail->SMTPAuth = true;

    $mail->Username = "you@domain.com";

    $mail->Password = "EmailPassword";

    $mail->From = "you@domain.com";

    $mail->FromName = "Your Name";

    $mail->AddAddress("user@domain.com");

    $mail->IsHTML(true);

    $mail->Subject = "Test message sent using the PHPMailer component";

    $mail->Body = "This is a test message.";

    $mail->Send()

    ?>'

    I updated all the fields and this works like a charm. My thinking is that somehow I need to integrate the code from the default phpmailer ($mail??) into the code in the functions.php.

    I am not even a coder of php, I just have been following the troubleshooting instructions, but to no avail. Any help would be much appreciated.

    [edit] Also, I've created a php info file, but there's no sendmail path. I don't have root access, so it doesn't matter anyway. Also, Brinkster runs windows servers [/edit]

    [edit2] I switched my e-mail in both users and options in the admin section of the wp control panel to admin@mydomain.com, so no problems there [/edit2]

  27. al_gorithm
    Member
    Posted 9 years ago #

    Macmanx,

    Thanks for your help, but that codex only references this thread anyway, and I've read through all the solutions and tried them with no changes. I don't have root access and I can't install any new phpmail scripts on the server, so I can't try a different method. Please advise if using Brinkster's current phpmailer, I can use wordpress at all.

    Thanks.

  28. johndoe77
    Member
    Posted 9 years ago #

    Al-

    Were you able to get this working? I just installed 1.5.1.1 and not my users or test accounts are getting the password email either.

    jd

  29. lifecruiser
    Member
    Posted 9 years ago #

    Thanks, I had that problem t0o and fixed it with the bug fix Ryan was linking to. Did all of the other suggestions before without any luck, but when removing the $more everything went fine!

Topic Closed

This topic has been closed to new replies.

About this Topic