Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

When a user registers on my wordpress site, it does not send them an email containing the password.

I do notice that an email was sent when a users email is @mydomain.com, but for others let say gmail.com or yahoo.com, it does not send an email.

How do I fix it?

share|improve this question
    
I'm not sure what your using as your backend (eg: cpanel). But can you send an email from your server to gmail.com or yahoo.com email address? Also are you saying that when the user uses your domain name, then the email is sent? –  Vincent P Jan 29 '13 at 10:30
    
im using cpanel. I can send in webmail to gmail.com email address. Yes, the email was sent when a user from my domain name. –  JR Galia Jan 29 '13 at 10:37
    
the problem is on wordpress. :-( –  JR Galia Jan 29 '13 at 10:38
    
Does the reset password send emails? Is there anything in your log file? –  Tom J Nowell Jan 29 '13 at 10:40
    
reset password only work for email with mydomain, for other's like gmail.com or yahoo.com, it wont. –  JR Galia Jan 29 '13 at 10:42
show 1 more comment

1 Answer

While not a solution as such, I would suggest you send a couple of test emails to isolate the issue and verify how and where things go wrong. Perhaps your email is actually sent, but rejected by the remote mail server due to missing some headers etc. The code below might help you determine this. Temporarily put it in functions.php. wp_mail will return true on success and false otherwise.

function email_test() {
    $test1 = wp_mail( user@yourdomain.com, "Test 1", "Just testing" );
    $test2 = wp_mail( user@otherdomain.com, "Test 2", "Just testing some more" );

    var_dump($test1);
    var_dump($test2);
    var_dump(ini_get('smtp_port'));

    die();
}
add_action('plugins_loaded', 'email_test');

There are a few SMTP related PHP settings which might influence the behavior of mail() and in turn wp_mail(). If you are using shared hosting I would suggest you simply describe the problem to you hosting provider and have them adjust the settings, or hopefully they'll be able at least to point you in the right direction.

I have also seen some issues with email being sent, but rejected by the remote server due to missing headers. While wp_mail should take care of most of these, adding headers like From, Reply-To, Return-Path, Organization, X-PHP-Script might sometimes help (check out the fourth argument for wp_mail).

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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