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

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

mail("[email protected]", "eric-linux test", "test") or die("can't send mail"); 

运行该脚本时,我从PHP中没有得到任何错误。

在我的php.ini文件是:

 sendmail_path = /usr/lib/sendmail -t -i 

 $ sudo ps aux | grep sendmail eric 2486 0.0 0.4 8368 2344 pts/0 T 14:52 0:00 sendmail -s “Hello world” [email protected] 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 

当我运行$ sendmail启动它只是挂在那里什么都不做。 我安装了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) 

谢谢

你真的需要安装完整的mta吗? 我从来没有使用sendmail,只有1个后缀安装我所有的服务器。 在所有其他我使用ssmtp 。 如果您的服务器不需要接收电子邮件,则configuration更简单,使用效率更高。

尝试“strace”sendmail来理解为什么会阻塞。

也尝试将其configuration为使用智能主机(例如,您的内部networking邮件中继服务器,询问系统pipe理员):

 yum|apt-get install sendmail-cf vim /etc/mail/sendmail.mc define(`SMART_HOST',`smtpserver.tld') 

要么

 define(`SMART_HOST',`localhost') <-- to enforce sendmail to use your postfix 

注意在这个奇怪的语法

 dnl define(`SMART_HOST',`smtpserver.tld') 

是一个注释行!!! 所以如果你在smart_host的默认行上find了,就去掉dnl

build立conf

 m4 sendmail.mc > sendmail.cf service sendmail restart 

testing它:

 sendmail -s "Test" [email protected] 

请尝试使用文档中的示例 。 如果它工作,很可能你忘了传递额外的信息到邮件()。 否则,要查找的区域将是您的sendmailconfiguration。

你检查过防火墙吗? 我configuration了一个严格的防火墙阻止所有input和输出端口,除了守护进程使用的端口之外,我一直在拉我的头发来解决这个问题。