WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. -

  2. person1229
    Member
    Posted 9 years ago #

    Is there just a way to stop WP from sending those mails and allow the user to pick thier own?

  3. oconnor
    Member
    Posted 9 years ago #

    Hi gang, I'm a Word Press newbie but I thought I would share my very simple solution to this problem IF; you are running on a Windows box AND you can modify the php.ini file in your Windows root directory.

    I made outgoing mail work on my new WP installation by editing the [mail function] parameters in php.ini to point at the SMTP server of my email provider. That's it. No patches, no SMTP emulators.

    Here is the "before" version of the file;

    SMTP = localhost ; for Win32 only
    smtp_port = 25
    sendmail_from= me@localhost ; for Win32 only

    Here's the "after" version;

    SMTP = mail.My-Provider-Use-Your-Own.com ; for Win32 only
    smtp_port = 25
    sendmail_from= MyEmail@Example.com ; for Win32 only

    Might work for you *Nix folks too.

  4. Bradley Jacobs
    Member
    Posted 8 years ago #

    I finally figured out how to fix this. All you need to do is fix the mail function in pluggable-functions.php in your include directory.

    The function looks something like this:

    if ( !function_exists('wp_mail') ) :
    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);
    }
    endif;

    For Brinkster, you want to rewrite it like this:

    if ( !function_exists('wp_mail') ) :
    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);

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

    $mail = new PHPMailer();

    $mail->IsSMTP();

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

    $mail->SMTPAuth = true;

    $mail->Username = "User@yourdomain.com";

    $mail->Password = "your-pass-here";

    $mail->From = "User@yourdomain.com";

    $mail->FromName = "User";

    $mail->AddAddress($to);

    $mail->IsHTML(true);

    $mail->Subject = $subject;
    $mail->Body = $message;

    $mail->Send();

    }
    endif;

    This should be the simplest possible solution. You don't have to change any other settings in any files. I had no access to the php.ini file or other external files because my host doesn't permit it. So this is what I came up with using Brinkster's documentation and what I was able to figure out from WordPress.

    Hope this helps!

    Crazy.

  5. cywebguy
    Member
    Posted 8 years ago #

    i am hosting with crystaltech, whom i love...

    but i cannot figure out the particulars of revising pluggable-functions.php to work within their hosting environment...

    has anyone had success with crystaltech and figured out how to get the email functionality for wordpress to work correctly?

    Any help would be greatly appreciated!!

    thanks cy

  6. digital472
    Member
    Posted 8 years ago #

    I have an interesting problem. I too am not receiving users passwords when they register. I have been looking over this discussion and noticed a lot of references to the file wp-includes/functions.php. Specifically the wp_mail area of the file. However when I searched the file for this area it doesn't appear to exist! This is a fresh install, no previous editing of these files. Any ideas? If someone could post the full function that is supposted to be in that file so I can add it in that would be great! This is running on a linux box.

  7. EternalCow
    Member
    Posted 8 years ago #

    I'm having this same problem hosting with GoDaddy. I've tried phpMailer with no success. I've searched the function files and can find no reference to wp_mail. The link to ryan's patch doesn't seem to be working anymore. Any suggestions? Thanks. :)

  8. nicky_uk
    Member
    Posted 8 years ago #

    I had the same problem. The blog resides with my host, and this is how I resolved the issue.

    In wp-includes/pluggable-functions.php on line 115 (in my editor) the code says:

    if ( !function_exists('wp_mail') ) :
    function wp_mail($to, $subject, $message, $headers = '') {
    if( $headers == '' ) {
    $headers = "MIME-Version: 1.0n" .
    "From: wordpress@" . preg_replace('#^www.#', '', strtolower($_SERVER['SERVER_NAME'])) . "n" .
    "Content-Type: text/plain; charset=\"" . get_settings('blog_charset') . "\"n";

    Note the "From: wordpress@" . preg_replace

    All I did was add a new standard email addy, for example:

    myemailprefix@ntlworld.com

    >"From: myemailprefix@"

    And amended the code to read:

    if ( !function_exists('wp_mail') ) :
    function wp_mail($to, $subject, $message, $headers = '') {
    if( $headers == '' ) {
    $headers = "MIME-Version: 1.0n" .
    "From: myemailprefix@" . preg_replace('#^www.#', '', strtolower($_SERVER['SERVER_NAME'])) . "n" .
    "Content-Type: text/plain; charset=\"" . get_settings('blog_charset') . "\"n";

    Note the "From: myemailprefix@"

    I'm guessing you need to use an email address provided by your host i.e. your usual address for your website.

    Anyway, it worked for me, so hope it helps someone.

  9. lzeltzer
    Member
    Posted 8 years ago #

    Frustration: WordPress 2.01 same issue. The admin account receives an email about a new user from wordpress@domain.com . I actually created an email account wordpress@domain.com; still nothing to the new user.

    Ideas?

  10. clarke_187
    Member
    Posted 8 years ago #

    BUMP...same issue...

  11. jkuruppu
    Member
    Posted 8 years ago #

    I couldn't get the registration notices to get sent until I loaded the wpPHPMailer plugin ( http://www.coffee2code.com/archives/2004/06/28/plugin-wpphpmailer/ and it works fine, BUT - i cannot figure out how to get the "From:" populated. I tried setting the hardcoding options in the Option setting for wpPHPMailer from within the admin GUI for WordPress - that prevented all mails from going out. then i tried altering the From: headers within the file: class.phpmailer.php - that didn't work. and i've tried altering the pluggable-functions.php file as nicky_uk suggested above....nothing works!!

    it's exceedingly frustrating, because many of my users have mail servers which dump any email lacking a "From:" header into the spam bucket.

    any suggestions??

    also, like digital472, i've searched and searched the functions.php file for the "wp_mail" function, and it doesn't exist!!

  12. popf
    Member
    Posted 8 years ago #

    Me too , I think it does not work for windows+iis .
    ~~~~~~~~~~~~~~~~~~~~~
    The e-mail could not be sent.
    Possible reason: your host may have disabled the mail() function...
    ~~~~~~~~~~~~~~~~~~~~~

    http://ipopf.info/wp/wp-login.php?action=lostpassword

  13. shacker
    Member
    Posted 8 years ago #

    Having the same problem on a cPanel host with add-on domains, but not with main domains. I watched the exim_reject_log while registering a new user and saw this:

    2006-06-20 01:33:06 1FsbfW-0004kG-0p H=(userdomain.com) [203.56.140.212] F=<> rejected after DATA: there is no valid sender in any header line

    But in wp-includes/pluggable-functions.php, I had already altered the wp_mail function to include an explicit and valid From: address:

    "From: gooduser@userdomain.com" . "\n" .

    So I'm really puzzled as to why exim thinks there's no valid sender. Thoughts?

  14. shacker
    Member
    Posted 8 years ago #

    More research: The exim_reject_log shows the error above, and also shows the mail headers, which include these lines:

    Envelope-from: <>
    and
    F From:

    So it's clear that exim is dropping the welcome messages because it can't find any From: information. None of the modifications to pluggable_functions.php I've found in this thread have made any difference.

    Then I found what I thought was going to be a breakthrough -- phpinfo() showed "no value" for sendmail_from! So I added this to the .htaccess for the directory:

    php_value sendmail_from user@domain.com

    Now phpinfo() shows a valid send_mail_from value. Excellent. But no dice - If I tail the exim_reject_log and register a new user, I see that exim still sees no valid sender and refuses to send the message. Somehow it's not picking up on the .htaccess directive for send_mail_from.

    Again, a simple PHP mail test script in the same directory sends out just fine - this is definitely a WordPress thing.

    Suggestions welcome.

  15. Delbert
    Member
    Posted 8 years ago #

    The problem has just developed for me. New blogs ALWAYS sent an email to the user to inform them of password, but all of a sudden they've stopped. Nobody's done anything on the server and the qmail smtp server is still working just fine. I shall dig deep - might even tentatively try an upgrade to 2.03. Will let you know how it goes.

  16. xaddict
    Member
    Posted 8 years ago #

    I've got the 2.0.4 version of WP, I searched for the mail function in functions.php...and... THERE IS NONE
    I don't know if I did something or functions have been replaced or... some weird alien ate my code...

    Any ideas?

  17. stafford
    Member
    Posted 8 years ago #

    Same problem here.

    WP 2.0.4 and I cant register new user. Cant receive registration mail.

    I try to modify the function.php but no mail :(

  18. xaddict
    Member
    Posted 8 years ago #

    Do the people of wordpress know their latest stable build does not have a wp_mail() function in the functions.php file?
    Cause without that function (seems that's not the only thing they changed that has to do with mail) the whole program is quite useless (sorry to say it that way, but that's kind of... the truth)

  19. grasshoppermind
    Member
    Posted 8 years ago #

    You need to look in pluggable-functions.php, wp-mail is in there. Since this thread started a year ago there have been a number of upgrades since then so some of the earlier help may be out of date. The registration emails are not working for me either at the moment, but I've just installed 2.0.4. If I get it going I'll let you know.

  20. grasshoppermind
    Member
    Posted 8 years ago #

    @cywebguy

    You asked about crystaltech, I'm hosted there as well. Seems that sendmail functionality is not available on their Windows Boxes. They recommend use of Blat.exe which is installed and supported. This may be the case for other Windows Hosts? Calling Blat from within PHP is a bit beyond my coding capabilities so I'm out of ideas. Really need a developer guy on the case...

  21. brian0526
    Member
    Posted 8 years ago #

    This is weird. I can't send out confirmation emails to new users. But, the Subscribe2 plug-in works just fine. It sends confirmation email and notifications of new posts. I've turned off user registration for now, so that my customers can leave comments. But, I'd love to get this fixed to keep spam to a minimum.

  22. expertphp
    Member
    Posted 8 years ago #

    XPertMailer is the new solution for sending e-mails using php. With XPM2 you can send e-mails to inbox ( FromHost() ) and all you need it is a complete documentation for XPM2: http://www.xpertmailer.com/DOCUMENTATION
    XPertMailer it is the first php class that can send e-mails via a Relay SMTP Server with autentication and TLS/SSL connection. If you can't delivery the e-mail using mail() function then you have two options like 'Relay' or directly to the 'Client'. Enjoy :)

  23. gabrielheiser
    Member
    Posted 8 years ago #

    How I got WordPress email to work!

    I have a Windows dedicated server, running Windows Server 2003 Standard Edition. I just installed WordPress on that box, version 2.0.4. After installing WP, I could "register" but no email with the password was sent out. I have spent the better part of five days fiddling around with this and finally got it to work! Here's what I did:

    1. Use the wpPHPMailer plugin for WordPress instead of fooling around with sendmail. You can download it from here:
    http://www.coffee2code.com/archives/2004/06/28/plugin-wpphpmailer/
    Follow the installation instructions carefully. I did not need to change "mail()" call to "phpmailer()" in wp-login.php for password retrieval. I tried it both ways and it made no difference.

    2. Key ingredient: Go to Start, Programs, Administrative Tools, Internet Information Services. Expand your local computer. There should be an icon there for Default SMTP Virtual Server. Right-click that and select Properties. Click Access at the top menu. Click Relay. Check "Only the list below" and "Allow all computers which successfully authenticate to relay, regardless of the list above." Click Add. Enter the i.p. address of your site. Click OK, OK, and OK. Close the IIS Manager, now. This part is done!

    To set up SMTP on the box, I had to go to Start, Settings, Control Panel, Add or Remove Programs. Click "Add/Remove Windows Components." Check "E-mail services". This will install the SMTP and the POP3 services; you'll need both. Click Next, wait while it installs, then Finish. Close the window, etc. This part is now done.

    Finally, set up Outlook Express (the so-called "email client"): Go to Start, Programs, Outlook Express. Click Tools, Accounts, Mail, then Add, then Mail. Your name: irrelevant, since wpPHPMailer overrides this, so enter whatever you want and click Next. Enter an email address here; this is what WordPress will use to send notice of a new registration, via Outlook Express, but not the rest of the world.
    At this point, you may want to review this excellent tutorial: http://www.ilopia.com/Articles/WindowsServer2003/EmailServer.aspx

    Anyway, I finally got WP to talk to Outlook and Outlook to send emails to the rest of the world, but I could not get WP to send emails to the rest of the world (which of course is required to send out passwords to new registrants), until I installed the wpPHPMailer plugin and also added my i.p. address to the relay list, as described above.

    I'm sure others will have slightly different setups, but at least you may find some comfort in knowing that indeed WordPress and a Windows box running IIS can work together to allow comments and registration.

  24. Vip76Reis
    Member
    Posted 7 years ago #

    gabrielheiser

    Good, but and if the server is a unix? I had set phpmailer.php permissions to 777 but no success. I'm the admin and I've received the "new user notification" (my admin email adreesss anp phpmailer.php use the same smtp server).

    But there is something interesting: The field "From" has nothing written. But when I set wordpress to "Sendmail via mail() (Default WordPress mail handler)" I reveive the new user notificatoin whith the field "from" with admin email (wp uses admin mail address to mail users).

    But I want wpPHPMailer to do that to me. Some suggestion?

    After I changed the admin email to ccrstudio@gmail.com and i've received the new user notification. As I can see, thw WP is sending e-mails to external.

    I Think WP is not generating the new user pswd. and if there's no pswd, there's no email...

    help unix servers users!

  25. fcjam
    Member
    Posted 7 years ago #

    did anyone ever find a solution to this?

  26. kulangara
    Member
    Posted 7 years ago #

    Hi oconnor

    I loved your simple solution for a Windows box. I am running WP on Windows 2003, with Apache etc all on one stand alone server .....so will your solution work as I am having the same problem with user registartion emails?

    I will try your fix tomorrow. I hope it does.
    Thanks again

    JJ

  27. gabster
    Member
    Posted 7 years ago #

    Kudos to Oconnor again!

    YOUR SIMPLE FIX DID IT!

    GAbi.

  28. happydays
    Member
    Posted 7 years ago #

    I still have the same problem. wordpress admin emails come through, just no user resgistration emails although bbpress on same server is fine, i get both.

    i think it's the difference of the [ ] marks around the e-mail from, bits, i have removed one lot from around the 'blogname' however i cant find the other [ ] comments to remove from the part where it shows the users email from. It does this when someone posts a contact from through as well, i see them in my spam folder.

    pleae help, though im sure 2.1 wordpress will be great and wont have anyproblems....mmm. cant complain though best free thing in the world!

Topic Closed

This topic has been closed to new replies.

About this Topic