【问题标题】:How can I get PHP mail() to work? Need help configuring a MTA如何让 PHP mail() 工作?需要帮助配置 MTA
【发布时间】:2010-11-03 00:30:48
【问题描述】:

更新:我解决了。记录以下所有内容。

我尝试了很多东西,但都不起作用。

我不介意使用 postfix、exim4 或 sendmail。我只需要一步一步的指导和解释我在做什么。我也在使用 Google Apps 发送电子邮件。

编辑:

邮件日志

Nov  3 01:14:02 mugbear postfix[16615]: error: to submit mail, use the Postfix sendmail command
Nov  3 01:14:02 mugbear postfix[16615]: fatal: the postfix command is reserved for the superuser

这是什么意思?


更新到编辑:通过使用sendmail_path = /usr/sbin/sendmail -t -i更正 php.ini 中的 sendmail_path 来修复

编辑2: PHP - 刚刚从文档中获取。仅供参考,我删除了我的电子邮件。

<?php
// The message
$message = "Line 1\nLine 2\nLine 3";

// In case any of our lines are larger than 70 characters, we should use wordwrap()
$message = wordwrap($message, 70);

// Send
mail('removed@gmail.com', 'My Subject', $message);

?>

编辑3: 另一个错误:

Nov  3 07:22:29 mugbear postfix/postdrop[17131]: warning: unable to look up public/pickup: No such file or directory
Nov  3 07:22:29 mugbear postfix/postdrop[17133]: warning: unable to look up public/pickup: No such file or directory

对 edit3 的更新:使用以下链接修复了此问题:http://ubuntuforums.org/showthread.php?t=666018 运行这个:

sudo mkfifo /var/spool/postfix/public/pickup
sudo /etc/init.d/postfix restart

之后,你会得到这个错误:

 postfix/master[13902]: fatal: bind 0.0.0.0 port 25: Address already in use

然后你将不得不检查你的进程并杀死 sendmail 进程,例如:

root@server:/etc/postfix# ps aux | grep mail
root     23554  0.0  0.0   8232  1900 ?        Ss   10:17   0:00 sendmail: MTA: accepting connections          
root     27308  0.0  0.0   3004   764 pts/0    S+   10:30   0:00 grep mail
root@server:/etc/postfix# kill 23554

编辑4: 这是什么意思?

Nov  3 07:34:51 mugbear postfix/pickup[17309]: 6602F1C151: uid=33 from=<www-data>
Nov  3 07:34:51 mugbear postfix/cleanup[17311]: 6602F1C151: message-id=<20101103073451.6602F1C151@mugbear.xen.prgmr.com>
Nov  3 07:34:51 mugbear postfix/qmgr[17310]: 6602F1C151: from=<www-data@mugbear.com>, size=397, nrcpt=1 (queue active)
Nov  3 07:34:51 mugbear postfix/error[17321]: 6602F1C151: to=<mugbear@gmail.com>, relay=none, delay=0.03, delays=0.02/0/0/0.01, dsn=4.3.5, status=deferred (delivery temporarily suspended: Host or domain name not found. Name service error for name=xen.prgmr.com type=A: Host found but no data record of requested type)

更新到 edit4:我运行 dpkg-reconfigure postfix 并选择了 Internet Site

【问题讨论】:

    标签: php email debian


    【解决方案1】:

    您是否正确安装了后缀?如果是 : 服务后缀重启

    纳米/etc/php.ini

    找到 sendmail_path ,改行为 sendmail_path = /usr/sbin/sendmail.postfix -t -i

    这里是php客户端的完整服务器/客户端安装说明http://setahost.com/installing-postfix-as-a-default-mail-sending-program-with-php/

    按照客户端安装说明...

    【讨论】:

      【解决方案2】:

      什么不工作?服务器日志显示什么(PHP 和邮件)?您需要确定问题出在 PHP 还是您的 MTA。

      恕我直言,设置只发送后缀,然后使用 PEAR 邮件库可能是最好的选择。

      【讨论】:

      • 我会接受任何解决方案,只要它有效,你能给我一些指导吗?
      • 每当我忘记如何操作时,我都会按照标准的 CentOS 说明进行操作。不过,为 sendonly 配置 Postfix 非常简单。应该有一个 Debian 指南来执行此操作。不过,您确实需要查看 httpd 错误日志和邮件日志以了解问题所在。我想到的两个问题是PHP尝试发送时缺少标头(缺少From:通常是罪魁祸首),或者是MTA配置问题(很多时候,您只需将MTA配置为直接连接到远程端)。
      • 通常 (?) postfix 会安装,因此它看起来就像用于发送邮件的 sendmail,并且也位于正常的 sendmail 位置。你的 PHP 是什么样的?
      • @Doug,该错误表明您没有正确配置 php.ini 中的 sendmail 命令,并且它正在调用 postfix 二进制文件,期望它的行为类似于普通的 sendmail 二进制文件。
      猜你喜欢
      • 2017-09-22
      • 2015-02-11
      • 2011-02-25
      • 1970-01-01
      • 2020-11-15
      • 1970-01-01
      • 2014-08-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多