FIXED: WordPress refuses to send you a Password Reset Link

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





Jay is the CEO and founder of WP Hosting, a boutique style managed WordPress hosting and support service. He has been working with Plesk since version 9 and is a qualified Parallels Automation Professional. In his spare time he likes to develop iOS apps and WordPress plugins, or draw on tablet devices. He blogs about his coding journey at http://wpguru.co.uk and http://pinkstone.co.uk.