I'm getting an error while using the password reset option in my Lightsail WordPress website's login page. How can I fix this?

Last updated: 2021-10-20

When using the Lost Password option on the login page of my Amazon Lightsail WordPress website, I receive the error: "The email could not be sent. Your site may not be correctly configured to send email". I also can't send emails from my WordPress website using PHP mailer. How do I fix these issues?

Short description

The PHP mail function uses the sendmail application to send emails. PHP mailer and the Forgot Password option, which depends on PHP mailer, won't work in the following scenarios:

  • The sendmail application isn't installed in the instance.
  • The sendmail binary location isn't correctly configured in the PHP configuration file.

Resolution

1.    Verify that sendmail is installed by running the following command. If you receive the error command not found after running the command, then sendmail isn't installed.

sudo /usr/sbin/sendmail -q

2.    If sendmail isn't installed, then install it by running the following command:

OS distributions such as Debian and Ubuntu

sudo apt-get install sendmail

OS distributions such as Amazon Linux 2 and CentOS

sudo yum install sendmail

3.    Run the following command to configure PHP to use sendmail. This command modifies the PHP configuration file /opt/bitnami/php/etc/php.ini.

sudo sed -i.$(date +%F_%R) '/sendmail_path/c\sendmail_path = "env -i /usr/sbin/sendmail -t -i"' /opt/bitnami/php/etc/php.ini

4.    Run the following command to restart PHP-FPM:

sudo /opt/bitnami/ctlscript.sh restart php-fpm

5.    Use the password reset option on the log in page to verify that it now works.


Did this article help?


Do you need billing or technical support?