Ubuntu
Ubuntu/Postfix 沒有收到來自外部的電子郵件
我正在嘗試將我的 Amazon EC2 實例配置為接收帶有後綴的電子郵件。我嘗試了幾個小時,但我從未收到過電子郵件。如果我從同一伺服器終端發送電子郵件,它可以工作。這是有效的
echo "My message" | mail -s subject noreply@example.com
但是,如果我嘗試像 gmail 一樣從外部發送電子郵件。我沒有收到。我的 25 埠是開放的。我也沒有收到任何傳遞失敗的消息。也無法從 postfix 日誌中找到任何相關問題。如果有人可以幫助我解決這個問題,我會很感激。
這是我的後綴配置文件。
# 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. smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination myhostname = example.com virtual_alias_maps = hash:/etc/postfix/virtual alias_database = hash:/etc/aliases myorigin = /etc/mailname mydestination = example.com relayhost = mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 mailbox_size_limit = 0 recipient_delimiter = + inet_interfaces = all inet_protocols = all alias_maps = hash:/etc/aliases
正如亞歷克斯建議的那樣,swaks 的輸出如下所示。
=== Trying 52.62.94.158:25... === Connected to 52.62.94.158. <- 220 example.com ESMTP Postfix (Ubuntu) -> EHLO ip-172-31-21-89.ap-southeast-2.compute.internal <- 250-example.com <- 250-PIPELINING <- 250-SIZE 10240000 <- 250-VRFY <- 250-ETRN <- 250-STARTTLS <- 250-ENHANCEDSTATUSCODES <- 250-8BITMIME <- 250 DSN -> MAIL FROM:<test@gmail.com> <- 250 2.1.0 Ok -> RCPT TO:<noreply@example.com> <- 250 2.1.5 Ok -> DATA <- 354 End data with <CR><LF>.<CR><LF> -> Date: Sat, 12 Mar 2016 23:08:43 +1100 -> To: noreply@example.com -> From: test@gmail.com -> Subject: Test -> X-Mailer: swaks v20130209.0 jetmore.org/john/code/swaks/ -> -> This is a test mailing -> -> . <- 250 2.0.0 Ok: queued as E44EE642AD -> QUIT <- 221 2.0.0 Bye
我已經收到了那封電子郵件。然後我再次嘗試從我的 Gmail 中發送電子郵件。不幸的是它失敗了。當我嘗試從這裡查看我的 noreply@example.com 電子郵件時。它說“壞” http://verify-email.org/
您的 MX 記錄指向 name
smtp.example.com
,但該 name 沒有任何地址記錄。$ host example.com example.com has address 52.62.94.158 example.com mail is handled by 10 smtp.example.com. $ host smtp.example.com Host smtp.example.com not found: 3(NXDOMAIN)
因此,您的域的郵件無法投遞。
只需添加第二個解決方案,這是完全和監督的,類似於您使用 MX 的解決方案。我能夠將電子郵件從伺服器發送到同一伺服器上的其他虛擬域。但我無法從伺服器外部接收任何內容,但能夠從其他虛擬域接收。
我只是忘記啟用防火牆。
sudo ufw allow Postfix sudo ufw enable sudo ufw status
希望它會在未來的某個時候對某人有所幫助。