我将php-mail-script从apache-server移动到nginx-server的根文件夹(ubuntu 12.0.4 lts,mysql,php5 fpm)。该表格在Apache-Server上完美工作,但是,当我尝试发送邮件时,我会收到错误消息。
。phpinfo()返回有关邮件设置的以下详细信息:
php-fpm - active
mail.add_x_header - On
mail.force_extra_parameters - no value
mail.log - no value
sendmail_from - no value
sendmail_path - /usr/sbin/sendmail -t -i
php.ini表示以下内容:
[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = localhost
; http://php.net/smtp-port
smtp_port = 25
; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from = me@example.com
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
;sendmail_path =
; Force the addition of the specified parameters to be passed as extra parameters
; to the sendmail binary. These parameters will always replace the value of
; the 5th parameter to mail(), even in safe mode.
;mail.force_extra_parameters =
; Add X-PHP-Originating-Script: that will include uid of the script followed by the filename
mail.add_x_header = On
; The path to a log file that will log all mail() calls. Log entries include
; the full path of the script, line number, To address and headers.
;mail.log =
/var/log/mail.log指出以下内容:
Jan 27 10:11:49 localhost sendmail[22457]: My unqualified host name (localhost) unknown; sleeping for retry
Jan 27 10:12:49 localhost sendmail[22457]: unable to qualify my own domain name (localhost) -- using short name
Jan 27 10:12:50 localhost sendmail[22457]: gethostbyaddr(192.241.186.7) failed: 1
Jan 27 10:12:50 localhost sendmail[22457]: gethostbyaddr(10.128.248.128) failed: 1
Jan 27 10:12:50 localhost sendmail[22457]: alias database /etc/mail/aliases rebuilt by root
Jan 27 10:12:50 localhost sendmail[22457]: /etc/mail/aliases: 4 aliases, longest 10 bytes, 66 bytes total
Jan 27 10:12:50 localhost sm-mta[22516]: My unqualified host name (localhost) unknown; sleeping for retry
Jan 27 10:12:52 localhost sm-msp-queue[22521]: My unqualified host name (localhost) unknown; sleeping for retry
Jan 27 10:13:50 localhost sm-mta[22516]: unable to qualify my own domain name (localhost) -- using short name
Jan 27 10:13:50 localhost sm-mta[22516]: gethostbyaddr(192.241.186.7) failed: 1
Jan 27 10:13:50 localhost sm-mta[22516]: gethostbyaddr(10.128.248.128) failed: 1
Jan 27 10:13:50 localhost sm-mta[22523]: starting daemon (8.14.4): SMTP+queueing@00:10:00
Jan 27 10:13:52 localhost sm-msp-queue[22521]: unable to qualify my own domain name (localhost) -- using short name
Jan 27 10:14:10 localhost sendmail[22542]: My unqualified host name (localhost) unknown; sleeping for retry
Jan 27 10:15:10 localhost sendmail[22542]: unable to qualify my own domain name (localhost) -- using short name
Jan 27 10:15:10 localhost sendmail[22542]: s0RFFAmY022542: from=www-data, size=423, class=0, nrcpts=1, msgid=<201401271515.s0RFFAmY022542@$
Jan 27 10:15:10 localhost sm-mta[22546]: s0RFFAC7022546: from=<www-data@localhost>, size=638, class=0, nrcpts=1, msgid=<201401271515.s0RFF$
Jan 27 10:15:10 localhost sendmail[22542]: s0RFFAmY022542: to=example@outlook.com, ctladdr=www-data (33/33), delay=00:00:00, xdelay=00:00$
Jan 27 10:15:11 localhost sm-mta[22548]: s0RFFAC7022546: to=<example@outlook.com>, ctladdr=<www-data@localhost> (33/33), delay=00:00:01, $enter code here
这表明我的服务器上未正确设置php mail()?
我将感谢您的建议。
-
您是否已安装SendMail?如果没有,请看看这个线程https://stackoverflow.com/a/14886649/610880
-
检查/var/log/maillog(或任何邮件日志的任何错误)是否有任何错误?(或至少要验证邮寄的尝试)。
-
也向我们显示您的PHP错误日志中的任何错误。
-
另外,您的fpm安装chroot是吗?这可能会导致这样的问题。
-
尝试使用php(CLI和FPM)的phpinfo(),并比较sendmail_path指令的值。
-
另外,请确保Sendmail在您的路上,并且您没有更改下列
int /usr/local/etc/php/php-fpm.conf ;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com
hostname
和hostname -f
的输出是什么?我的猜测是您的服务器没有完全合格的域名。
-
检查我们有完全合格的域名
/bin/hostname
-
它应该返回" ispconfig.example.com"之类的东西
- 如果不是,那么我们分配了一个主机名(例如ISPConfig):
echo ispconfig.example.com > /etc/hostname
/etc/init.d/hostname.sh
vi /etc/hosts
- 并添加类似但适当的行:
127.0.0.1 localhost.localdomain localhost
192.168.0.100 ispconfig.example.com ispconfig