FIXED: WordPress refuses to send you a Password Reset Link

- by

Screen Shot 2015-02-10 at 21.33.07

I ran into an interesting problem today: on a CentOS 6 server a colleague of mine wanted to reset her WordPress password via the handy link provided in the login dialogue. But rather than sending an email, WordPress got back to her with the following error message:

The e-mail could not be sent.
Possible reason: your host may have disabled the mail() function.

Intrigued I had a look at the server. To my surprise sendmail was installed, and emails could be sent from the command line as well as from PHP scripts. But not from WordPress. What was going on?

Examining the logs I came across the following error message:

sendmail: fatal: chdir /var/spool/postfix: Permission denied

followed by a Web Server 500 error caused by the password reset link. Interesting.

Turns out it was an old acquaintance of mine, someone who has been spoiling the broth on many occasions: SELinux.

SELinux can prevent Apache from sending mail when enabled, but lucky for us there’s a quick way to fix this, courtesy of manyon over at the Simple Machines Forum.

To test if SELinux is preventing mail from being sent, try this test from the command line:

/usr/sbin/getsebool httpd_can_sendmail

It will return with httpd_can_sendmail –> on or off, and if your server is set to the latter then mail can’t be sent.

To change this, execute the following, switching this bool to on:

sudo setsebool -P httpd_can_sendmail 1

Note that this can take a minute or two (literally) because the entire SELinux policy needs to be recompiled. Be patient, your server isn’t hanging.

Once changed, make sure to restart Apache:

service httpd restart

Now WordPress can send the password reset link. #result



If you enjoy my content, please consider supporting me on Ko-fi. In return you can browse this whole site without any pesky ads! More details here.

2 thoughts on “FIXED: WordPress refuses to send you a Password Reset Link”

  1. Hi, thank you for sharing your experience. We have experienced this error as well, WordPress won’t send any email at all, like the subscription or the contact form submission, etc.
    But I don’t really understand what is the SELinux, how do I know if we have the same issue?
    How to input the commend line to test it?

    Many thanks

    Luke

Leave a Comment!

This site uses Akismet to reduce spam. Learn how your comment data is processed.