連接超時 - PHP 聯繫表單的簡單出站後綴
好的,所以我只有一個 PHP 聯繫表單的 Postfix,它將向單個 . 我只希望它向單個外部地址 (foo@example.com) 發送郵件。我有域 sub1.sub2.domain.com。我從 Ubuntu 儲存庫中安裝了 Postfix,只進行了最少的配置更改。我無法讓 Postfix 向外部發送郵件(儘管內部帳戶可以成功,這是不必要的)。
如果我使用 PHP mail() 生成電子郵件,電子郵件只會延遲。如果我嘗試在 telnet 中形成自己的,請在 rcpt 之後立即:
$$ email $$foo@example.com$$ /email $$,我得到一個
postfix/smtpd[31606]: NOQUEUE: reject: RCPT from localhost[127.0.0.1]: 550 5.1.1 <foo@example.com>: Recipient address rejected: example.com; from=<root@localhost> to=<foo@example.com> proto=ESMTP helo=<localhost>
當註釋掉 default_transport = error 和 relay_transport = error 行時,我得到以下資訊:
Jun 26 14:33:00 sub1 postfix/smtp[12191]: 2DA06F88206A: to=<bar@gmail.com>, relay=none, delay=514, delays=409/0.01/105/0, dsn=4.4.1, status=deferred (connect to aspmx3.googlemail.com[74.125.127.27]:25: Connection timed out) Jun 26 14:36:36 sub1 postfix/smtp[12225]: connect to mta7.am0.yahoodns.net[98.139.175.224]:25: Connection timed out Jun 26 14:38:00 sub1 postfix/smtp[12225]: 22952F88208E: to=<foo@yahoo.com>, relay=none, delay=655, delays=550/0.01/105/0, dsn=4.4.1, status=deferred (connect to mta5.am0.yahoodns.net[67.195.168.230]:25: Connection timed out)
我的 main.cf
# See /usr/share/postfix/main.cf.dist for a commented, more complete version # Debian specific: Specifying a file name will cause the first # line of that file to be used as the name. The Debian default # is /etc/mailname. #myorigin = /etc/mailname smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu) biff = no # appending .domain is the MUA's job. append_dot_mydomain = no # Uncomment the next line to generate "delayed mail" warnings #delay_warning_time = 4h readme_directory = no # TLS parameters smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key smtpd_use_tls=yes smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache # See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for # information on enabling SSL in the smtp client. myhostname = sub1.sub2.domain.com alias_maps = hash:/etc/aliases alias_database = hash:/etc/aliases myorigin = /etc/mailname mydestination = sub1.sub2.domain.com, localhost relayhost = mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 mailbox_size_limit = 0 recipient_delimiter = + inet_interfaces = all default_transport = error relay_transport = error
此外, dig sub1.sub2.domain.com MX 返回:
; <<>> DiG 9.7.0-P1 <<>> sub1.sub2.domain.com MX ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 4853 ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0 ;; QUESTION SECTION: ;sub1.sub2.domain.com. IN MX ;; AUTHORITY SECTION: sub2.domain.com. 600 IN SOA sub2.domain.com. sub5.domain.com. 2012062915 7200 600 1209600 600 ;; Query time: 0 msec ;; SERVER: x.x.x.x#53(x.x.x.x) ;; WHEN: Fri Jun 29 16:35:00 2012 ;; MSG SIZE rcvd: 84
lsof -i 返回空
網路統計-t -a | grep LISTEN 返回
tcp 0 0 localhost:mysql *:* LISTEN tcp 0 0 *:ftp *:* LISTEN tcp 0 0 *:ssh *:* LISTEN tcp 0 0 localhost:ipp *:* LISTEN tcp 0 0 *:smtp *:* LISTEN tcp6 0 0 [::]:netbios-ssn [::]:* LISTEN tcp6 0 0 [::]:www [::]:* LISTEN tcp6 0 0 [::]:ssh [::]:* LISTEN tcp6 0 0 localhost:ipp [::]:* LISTEN tcp6 0 0 [::]:microsoft-ds [::]:* LISTEN
- 你有沒有配置防火牆?
- 您的託管服務提供商是否安裝了防火牆?
其中之一很可能是問題所在。
詢問您的託管服務提供商是否允許埠 25 上的出站連接。如果不允許,請詢問是否有智能主機。
您可以使用 . 檢查主機的防火牆
iptables -L -nv
。兩行:
default_transport = error default_relay = error
也會給你帶來麻煩。如果您沒有智能主機,則可以將這兩個註釋掉並回退到預設值,或者,如果有,將其添加為
default_relay
.如果您要發送到 Google 應用程序帳戶,您可以將伺服器的 IP 地址列入白名單。其他電子郵件提供商可能會提供相同的服務。如果您無法將您的伺服器與您發送給的任何人一起列入白名單,那麼您將需要完成所有正常的傳遞任務:SPF、反向 DNS、有效的郵件名、DKIM、DMARC、RFC 地址(郵遞員等)、有效退回地址,退回地址域的 MX 記錄,退回監控。