Centos
Postfix 能接收郵件但不能發送
我在我的機器上執行了 postfix(帶有 centos 最小),但今天我將它配置為使用我的域,例如這是我的域名
example.com
。這是我的配置: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 header_checks = regexp:/etc/postfix/header_checks html_directory = no inet_interfaces = all inet_protocols = ipv4 mail_owner = postfix mailbox_size_limit = 1073741824 mailq_path = /usr/bin/mailq.postfix manpage_directory = /usr/share/man message_size_limit = 10485760 mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain mydomain = example.com myhostname = mail.example.com mynetworks = 127.0.0.0/8 mynetworks_style = host myorigin = $mydomain newaliases_path = /usr/bin/newaliases.postfix queue_directory = /var/spool/postfix readme_directory = /usr/share/doc/postfix-2.6.6/README_FILES relayhost = smtp.$mydomain sample_directory = /usr/share/doc/postfix-2.6.6/samples sendmail_path = /usr/sbin/sendmail.postfix setgid_group = postdrop smtpd_banner = $myhostname ESMTP $mail_name smtpd_client_restrictions = permit_mynetworks,reject_unknown_client,permit smtpd_recipient_restrictions = permit_mynetworks,permit_auth_destination,permit_sasl_authenticated,reject unknown_local_recipient_reject_code = 550
我需要一個電子郵件帳戶才能發送電子郵件(密碼檢索等)。我今天在某處讀到,如果您創建 unix 帳戶後綴會將其辨識為電子郵件地址,因此如果您的帳戶使用者名是
ant
您的電子郵件,那麼您的電子郵件將是ant@example.com
.所以我對此進行了測試並嘗試發送電子郵件,
ant@example.com
並且我成功收到了郵件。當我嘗試使用 ant 任務腳本發送電子郵件時,我無法連接:
Failed messages: javax.mail.MessagingException: Could not connect to SMTP host: mail.example.com, port: 25; nested exception is: java.net.ConnectException: Connection timed out: connect
我在這裡想念什麼?
編輯
我可以遠端登錄到 localhost :
Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. 220 mail.example.com ESMTP Postfix
您在某處有一個防火牆,它拒絕與 postfix 的傳入連接。
查看以下輸出:
iptables-save
您缺少 DNS。要麼
mail.example.com
必須解析為 127.0.0.1,要麼必須將 mail.example.com 的 IP 添加到mynetworks
.