Centos 6 – Postfix不会发送到没有标志的自己的域名

我正在将网站移动到另一台服务器,并且遇到了PHP邮件的问题。 但只有当发送邮件到主机域例如[email protected]

mail($send_to, 'Web contact' ,$message,null,"-r [email protected]"); 

我可以通过邮件发送的唯一方法是添加-r标志,这似乎不在于标志后面input什么电子邮件地址。

这是从Centos 5迁移到6,我相信邮件现在使用Postfix而不是sendMail。

是否有一个Postfix设置,我可以改变停止必须添加此标志的每个电话的函数调用?

另外有没有办法强制使用sendMail,而不是使用Postfix,如果我不能解决这个问题?

我应该提到,我知道邮件是从日志中显示的内部路由:

编辑

这是没有标志的失败尝试

 May 14 16:13:12 test sendmail[10244]: t4EFDCLq010244: from=apache, size=169, class=0, nrcpts=1, msgid=<[email protected]>, relay=apache@localhost May 14 16:13:12 test postfix/smtpd[10245]: connect from localhost[127.0.0.1] May 14 16:13:12 test postfix/smtpd[10245]: 9EFB3256738: client=localhost[127.0.0.1] May 14 16:13:12 test postfix/cleanup[10248]: 9EFB3256738: message-id=<[email protected]> May 14 16:13:12 test sendmail[10244]: t4EFDCLq010244: [email protected], ctladdr=apache (48/48), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30169, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (Ok: queued as 9EFB3256738) May 14 16:13:12 test postfix/qmgr[10102]: 9EFB3256738: from=<[email protected]>, size=592, nrcpt=1 (queue active) May 14 16:13:12 test postfix/smtpd[10245]: disconnect from localhost[127.0.0.1] May 14 16:13:12 test postfix/smtp[10249]: 9EFB3256738: to=<[email protected]>, relay=mail.example.com[748.31.105.444]:25, delay=0.1, delays=0.04/0.01/0.01/0.03, dsn=5.0.0, status=bounced (host mail.example.com[748.31.105.444] said: 550-Verification failed for <[email protected]> 550-No Such User Here" 550 Sender verify failed (in reply to RCPT TO command)) May 14 16:13:12 test postfix/cleanup[10248]: B47B625675D: message-id=<[email protected]> May 14 16:13:12 test postfix/bounce[10250]: 9EFB3256738: sender non-delivery notification: B47B625675D May 14 16:13:12 test postfix/qmgr[10102]: B47B625675D: from=<>, size=2524, nrcpt=1 (queue active) May 14 16:13:12 test postfix/qmgr[10102]: 9EFB3256738: removed May 14 16:13:12 test postfix/smtp[10249]: B47B625675D: to=<[email protected]>, relay=mail.example.com[748.31.105.444]:25, delay=0.03, delays=0/0/0.01/0.02, dsn=5.0.0, status=bounced (host mail.example.com[748.31.105.444] said: 550 No Such User Here" (in reply to RCPT TO command)) May 14 16:13:12 test postfix/qmgr[10102]: B47B625675D: removed 

这是与国旗

 May 14 16:13:23 test sendmail[10251]: t4EFDN45010251: Authentication-Warning: example.com: apache set sender to [email protected] using -r May 14 16:13:23 test sendmail[10251]: t4EFDN45010251: [email protected], size=169, class=0, nrcpts=1, msgid=<[email protected]>, relay=apache@localhost May 14 16:13:23 test postfix/smtpd[10245]: connect from localhost[127.0.0.1] May 14 16:13:23 test postfix/smtpd[10245]: 3B3EF256738: client=localhost[127.0.0.1] May 14 16:13:23 test postfix/cleanup[10248]: 3B3EF256738: message-id=<[email protected]> May 14 16:13:23 test postfix/qmgr[10102]: 3B3EF256738: from=<[email protected]>, size=662, nrcpt=1 (queue active) May 14 16:13:23 test sendmail[10251]: t4EFDN45010251: [email protected], [email protected] (48/48), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30169, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (Ok: queued as 3B3EF256738) May 14 16:13:23 test postfix/smtpd[10245]: disconnect from localhost[127.0.0.1] May 14 16:13:24 test postfix/smtp[10249]: 3B3EF256738: to=<[email protected]>, relay=mail.example.com[748.31.105.444]:25, delay=1.4, delays=0.03/0/0.01/1.3, dsn=2.0.0, status=sent (250 OK id=1Ysup9-0001Rr-Jv) May 14 16:13:24 test postfix/qmgr[10102]: 3B3EF256738: removed 

问题似乎是用户的Apache被Postfix反弹,理想情况下,我希望Postfix无论如何发送这个用户。

后缀configuration

 alias_database = hash:/etc/aliases alias_maps = hash:/etc/aliases command_directory = /usr/sbin config_directory = /etc/postfix daemon_directory = /usr/libexec/postfix data_directory = /var/lib/postfix debug_peer_level = 2 html_directory = no inet_interfaces = localhost inet_protocols = all mail_owner = postfix mailq_path = /usr/bin/mailq.postfix manpage_directory = /usr/share/man mydestination = localhost.$mydomain mydomain = example.com newaliases_path = /usr/bin/newaliases.postfix queue_directory = /var/spool/postfix readme_directory = /usr/share/doc/postfix-2.6.6/README_FILES sample_directory = /usr/share/doc/postfix-2.6.6/samples sendmail_path = /usr/sbin/sendmail.postfix setgid_group = postdrop unknown_local_recipient_reject_code = 550 

首先你需要删除MTA中的一个。 在一个系统中有两个MTA可能会产生意想不到的结果。 因为我只有postfix的经验,所以我build议你删除sendmail 。 通过这个删除, mail命令将使用postfix代替sendmail作为默认代理。

 yum remove sendmail 

其次,你可以用sendmail_path参数在php.ini中设置默认的sendmail参数

 sendmail_path = '/usr/sbin/sendmail -t -i -f [email protected]' 

PS:根据这个手册页 , -r标志是-f标志的过时forms。 所以,我更喜欢使用-f

第三关于你的评论 :

从日志中我可以看到它弹起,因为[email protected]不存在。 我已经添加了,这解决了这个问题,但有没有在Postfix的设置,我可以添加,使[email protected]不需要创build?

这个错误信息

550- 550validation失败 – 没有这样的用户在这里“550发送者validation失败

没有被后缀抛出。 该邮件已被您实际的邮件服务器mail.**z*.net拒绝mail.**z*.net运行Exim 。 您需要与Eximpipe理员交谈,为什么它的行为如此

在你的main.cf有一个叫做mydestination的参数。 删除那里的域名forms,所以邮件到域将不会在本地交付。

之前:

 mydestination = $myhostname, $mydomain 

后:

 mydestination = $myhostname 

$myhostname应该保留在内部邮件的列表中(cron,apt,错误信息等)