我在 Ubuntu VPS 上运行 WordPress。当 WordPress 尝试发送电子邮件(如密码重置或注册电子邮件)时,它永远不会被送达。WordPress 使用 php 的mail()
功能。
我认为它不起作用是因为我的 VPS 没有安装 sendmail。所以我进入 SSH 并安装它,sudo apt-get install sendmail
似乎成功了。根据谷歌搜索到的更多建议,我编辑了 php.ini 文件以包含 sendmail 路径。
我发现它/usr/sbin/sendmail
对于许多 *nix 服务器来说都很常见。为了检查,我在 FTP 上浏览了此目录。“sendmail”目录似乎是一个快捷方式。这是正确的/预期的吗?
无论如何,php 邮件功能不起作用。我创建了一个 phpinfo 文件和一个测试邮件 php 文件,该文件仅包含一个mail()
以我的电子邮件作为收件人的函数。
笔记:我的 VPS 还没有域名,只有 IP 地址。这会影响 sendmail 功能吗?
我的 phpinfo 在这里供您参考:http://95.142.166.209/phpinfo.php
我还需要 Postfix 吗?我想我没有……
以下是部分邮件日志。我在最后执行了邮件功能:
Nov 27 18:41:02 sergeserver sm-msp-queue[5450]: unable to qualify my own domain name (sergeserver) -- using short name
Nov 27 19:00:01 sergeserver sm-msp-queue[5497]: My unqualified host name (sergeserver) unknown; sleeping for retry
Nov 27 19:01:01 sergeserver sm-msp-queue[5497]: unable to qualify my own domain name (sergeserver) -- using short name
Nov 27 19:20:01 sergeserver sm-msp-queue[5532]: My unqualified host name (sergeserver) unknown; sleeping for retry
Nov 27 19:21:01 sergeserver sm-msp-queue[5532]: unable to qualify my own domain name (sergeserver) -- using short name
Nov 27 19:40:01 sergeserver sm-msp-queue[5568]: My unqualified host name (sergeserver) unknown; sleeping for retry
Nov 27 19:41:01 sergeserver sm-msp-queue[5568]: unable to qualify my own domain name (sergeserver) -- using short name
Nov 27 20:00:01 sergeserver sm-msp-queue[5605]: My unqualified host name (sergeserver) unknown; sleeping for retry
Nov 27 20:01:01 sergeserver sm-msp-queue[5605]: unable to qualify my own domain name (sergeserver) -- using short name
Nov 27 20:20:01 sergeserver sm-msp-queue[5641]: My unqualified host name (sergeserver) unknown; sleeping for retry
Nov 27 20:21:01 sergeserver sm-msp-queue[5641]: unable to qualify my own domain name (sergeserver) -- using short name
Nov 27 20:40:01 sergeserver sm-msp-queue[5675]: My unqualified host name (sergeserver) unknown; sleeping for retry
Nov 27 20:41:01 sergeserver sm-msp-queue[5675]: unable to qualify my own domain name (sergeserver) -- using short name
Nov 27 21:00:01 sergeserver sm-msp-queue[5712]: My unqualified host name (sergeserver) unknown; sleeping for retry
Nov 27 21:01:01 sergeserver sm-msp-queue[5712]: unable to qualify my own domain name (sergeserver) -- using short name
Nov 27 21:20:02 sergeserver sm-msp-queue[5747]: My unqualified host name (sergeserver) unknown; sleeping for retry
Nov 27 21:21:02 sergeserver sm-msp-queue[5747]: unable to qualify my own domain name (sergeserver) -- using short name
Nov 27 21:40:01 sergeserver sm-msp-queue[5782]: My unqualified host name (sergeserver) unknown; sleeping for retry
Nov 27 21:41:01 sergeserver sm-msp-queue[5782]: unable to qualify my own domain name (sergeserver) -- using short name
Nov 27 22:00:01 sergeserver sm-msp-queue[5831]: My unqualified host name (sergeserver) unknown; sleeping for retry
Nov 27 22:01:01 sergeserver sm-msp-queue[5831]: unable to qualify my own domain name (sergeserver) -- using short name
Nov 27 22:20:01 sergeserver sm-msp-queue[5866]: My unqualified host name (sergeserver) unknown; sleeping for retry
Nov 27 22:21:01 sergeserver sm-msp-queue[5866]: unable to qualify my own domain name (sergeserver) -- using short name
Nov 27 22:37:19 sergeserver sendmail[5903]: My unqualified host name (sergeserver) unknown; sleeping for retry
Nov 27 22:38:19 sergeserver sendmail[5903]: unable to qualify my own domain name (sergeserver) -- using short name
Nov 27 22:38:19 sergeserver sendmail[5903]: qARLcJYI005903: from=adminftp, size=158, class=0, nrcpts=0, msgid=<201211272138.qARLcJYI005903@sergeserver>, relay=adminftp@localhost
答案1
您要么需要 postfix,要么需要 sendmail。它们的作用相同,您不能同时安装它们。假设您继续使用 sendmail,请确定这台机器发送的邮件是什么样子,例如[email protected]
。请注意,您从 sendmail 收到两个错误:
第一个错误是My unqualified host name (sergeserver) unknown
,因此请确保中存在有关 sergeserver 的条目/etc/hosts
。
您收到的第二个错误是unable to qualify my own domain name (sergeserver)
。这意味着除了“简单”主机名(在您的例子中是 sergeserver)之外,该机器还必须具有使其在DNS系统。因此,如果您的 中有以下条目,将会很有帮助/etc/hosts
:
95.142.166.209 sergeserver sergeserver.domain.name
由于您似乎正在使用 Debian 或 Ubuntu 系统,因此sudo sendmailconfig
将为您重新启动 sendmail。尝试一下,看看会发生什么。如果仍然不起作用,请/etc/mail/sendmail.mc
在底部编辑并添加以下几行:
LOCAL_CONFIG
Dmsergeserver
Djsergeserver.domain.name
sudo sendmailconfig
看看会发生什么。