当我在 Lightsail WordPress 网站的登录页面中使用密码重置选项时,为什么会出现错误?

1 分钟阅读
0

在我的 Amazon Lightsail WordPress 网站登录页面的“丢失密码”选项中,我收到错误消息: “The email could not be sent.Your site may not be correctly configured to send email”。我也无法使用 PHP 邮件程序从我的 WordPress 网站发送电子邮件。

概述

PHP 邮件函数使用 sendmail 应用程序发送电子邮件。PHP 邮件程序和“忘记密码”选项取决于 PHP 邮件程序。它在以下情况下不起作用:

  • 该实例中未安装** sendmail **应用程序。
  • 在 PHP 配置文件中未正确配置 sendmail 二进制文件位置。

解决方案

  1. 运行以下命令以验证是否已安装 sendmail。如果您收到错误:command not found,则说明未安装 sendmail。

    sudo /usr/sbin/sendmail -q
  2. 如果未安装 sendmail,则运行以下命令进行安装:
    操作系统发行版,例如 Debian 和 Ubuntu


    sudo apt-get install sendmail

    操作系统发行版,例如亚马逊 Linux 2 和 CentOS


    sudo yum install sendmail
  3. 运行以下命令将 PHP 配置为使用 sendmail。此命令修改 PHP 配置文件 /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. 运行以下命令来重启 PHP-FPM

    sudo /opt/bitnami/ctlscript.sh restart php-fpm
  5. 使用登录页面上的密码重置选项来验证它现在是否可以运行。

AWS 官方
AWS 官方已更新 1 年前