Centos 6 - Postfix 不會在沒有標誌的情況下發送到自己的域
我正在將站點移動到另一台伺服器,並且遇到了 PHP 郵件問題。但僅當向主機域發送郵件時,例如anything@example.com。
mail($send_to, 'Web contact' ,$message,null,"-r support@example.com");
我可以發送郵件的唯一方法是添加 -r 標誌,在標誌之後輸入什麼電子郵件地址似乎無關緊要。
這是從 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=<201505141513.t4EFDCLq010244@example.com>, 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=<201505141513.t4EFDCLq010244@example.com> May 14 16:13:12 test sendmail[10244]: t4EFDCLq010244: to=support@example.com, 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=<apache@example.com>, 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=<support@example.com>, 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 <apache@example.com> 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=<20150514151312.B47B625675D@example.com> 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=<apache@example.com>, 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 test@example.com using -r May 14 16:13:23 test sendmail[10251]: t4EFDN45010251: from=test@example.com, size=169, class=0, nrcpts=1, msgid=<201505141513.t4EFDN45010251@example.com>, 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=<201505141513.t4EFDN45010251@example.com> May 14 16:13:23 test postfix/qmgr[10102]: 3B3EF256738: from=<test@example.com>, size=662, nrcpt=1 (queue active) May 14 16:13:23 test sendmail[10251]: t4EFDN45010251: to=support@example.com, ctladdr=test@example.com (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=<support@example.com>, 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 無論如何都發送給這個使用者。
後綴配置
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 的經驗,所以我建議你刪除 sendmail。刪除後,
yum remove sendmail
其次,您可以在 php.ini中使用
sendmail_path
參數設置預設的 sendmail 參數,例如sendmail_path = '/usr/sbin/sendmail -t -i -f test@example.com'
PS:根據這個手冊頁,
-r
標誌是標誌的過時形式-f
。所以,我更喜歡使用-f
.第三關於您的評論:
從日誌中我可以看到它正在彈跳,因為 apache@example.com 不存在。我已經添加了這一點,這解決了問題,但是我可以添加 Postfix 中的設置以便不需要創建 apache@example.com 嗎?
此錯誤消息
550-驗證失敗 550-此處沒有此類使用者” 550 發件人驗證失敗
不是被後綴拋出的。該電子郵件已被您
mail.**z*.net
執行Exim的實際郵件伺服器拒絕。你需要和 Exim 管理員談談為什麼它會這樣