无法使用 sendmail 和 postfix 在 Ubuntu 桌面版本上运行 php mail()

5 ubuntu php sendmail

我正在运行 Ubuntu 9.10 LAMP 并尝试使用 PHP 进行简单的电子邮件测试,但没有收到任何电子邮件。

mail("myemail@gmail.com", "eric-linux test", "test") or die("can't send mail"); 
Run Code Online (Sandbox Code Playgroud)

运行该脚本时,我没有收到来自 PHP 的错误。

在我的 php.ini 文件中是:

sendmail_path = /usr/lib/sendmail -t -i
Run Code Online (Sandbox Code Playgroud)
$ sudo ps aux | grep sendmail
eric      2486  0.0  0.4   8368  2344 pts/0    T    14:52   0:00 sendmail -s “Hello world” myemail@gmail.com
eric      8747  0.0  0.3   5692  1616 pts/2    T    16:18   0:00 sendmail
eric      8749  0.0  0.3   5692  1636 pts/2    T    16:18   0:00 sendmail start
eric      9190  0.0  0.3   5692  1636 pts/2    T    19:12   0:00 sendmail start
eric      9192  0.0  0.3   5692  1616 pts/2    T    19:12   0:00 sendmail
eric      9425  0.0  0.3   5692  1620 pts/1    T    19:37   0:00 sendmail
eric      9427  0.0  0.3   6584  1636 pts/1    T    19:37   0:00 sendmail restart
eric      9429  0.0  0.3   5692  1636 pts/1    T    19:38   0:00 /usr/lib/sendmail restart
eric      9432  0.0  0.1   3040   804 pts/1    R+   19:38   0:00 grep --color=auto sendmail
Run Code Online (Sandbox Code Playgroud)

当我运行 $ sendmail start 它只是挂在那里什么也不做。我也安装了 postfix 看看它是否有帮助,但没有。

我试图查看端口 25:

eric@eric-linux:~$ telnet localhost 25
Trying ::1...
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 eric-linux ESMTP Postfix (Ubuntu)
Run Code Online (Sandbox Code Playgroud)

谢谢

小智 0

请尝试使用文档中的示例。如果有效,很可能您忘记将附加信息传递给 mail()。否则,要查找的区域将是您的 sendmail 配置。