Ubuntu

Exim4:“連接超時”無論轉發 smtp 伺服器

  • October 28, 2018

Exim 在具有公共 IP (scaleway.net) 的公共雲提供商的新配置 VM 上配置

目的:

能夠從 CLI(或腳本)向公共目標收件人(gmail、yahoo、…)發送郵件

結果:

Exim4 日誌文件**/var/log/exim4/mainlog**顯示所有測試伺服器(gmail、free.fr、online.net)的“連接超時”

配置細節:

lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.5 LTS
Release:    16.04
Codename:   xenial
  • 伺服器上沒有配置防火牆,也沒有來自云提供商的規則。
  • 解析的 smtp 伺服器 IP 地址(來自 exim 日誌文件)是可 ping 的。

使用不同的 smtp 伺服器進行測試:(gmail、free.fr、online.net)

貓 /etc/exim4/update-exim4.conf.conf

# /etc/exim4/update-exim4.conf.conf
#
# Edit this file and /etc/mailname by hand and execute update-exim4.conf
# yourself or use 'dpkg-reconfigure exim4-config'
#
# Please note that this is _not_ a dpkg-conffile and that automatic changes
# to this file might happen. The code handling this will honor your local
# changes, so this is usually fine, but will break local schemes that mess
# around with multiple versions of the file.
#
# update-exim4.conf uses this file to determine variable values to generate
# exim configuration macros for the configuration file.
#
# Most settings found in here do have corresponding questions in the
# Debconf configuration, but not all of them.
#
# This is a Debian specific file

dc_eximconfig_configtype='smarthost'
dc_other_hostnames=''
dc_local_interfaces='127.0.0.1 ; ::1'
dc_readhost=''
dc_relay_domains=''
dc_minimaldns='false'
dc_relay_nets=''
dc_smarthost='smtp.online.net::587'
CFILEMODE='644'
dc_use_split_config='false'
dc_hide_mailname='false'
dc_mailname_in_oh='true'
dc_localdelivery='mail_spool

使用 smtp 伺服器為每個測試正確配置的帳戶和密碼:

貓 /etc/exim4/passwd.client

#gmail-smtp.1.google.com:destination@gmail.com:pass1
#smtp.online.net:destination@online.net:pass2
smtp.free.fr:destination@free.fr:pass2

root@scw-5c50c6:~#tail -f /var/log/exim4/mainlog

root@scw-5c50c6:~# tail -f /var/log/exim4/mainlog
2018-10-27 17:32:47 1gGSDM-0002ib-5Y == destination1@gmail.com R=smarthost T=remote_smtp_smarthost defer (-53): retry time not reached for any host
2018-10-27 17:32:47 1gGSKT-0002sr-C6 == destination1@gmail.com R=smarthost T=remote_smtp_smarthost defer (-53): retry time not reached for any host
2018-10-27 17:32:47 1gGSF6-0002ij-UA == destination1@gmail.com R=smarthost T=remote_smtp_smarthost defer (-53): retry time not reached for any host
2018-10-27 17:32:47 1gGSJs-0002no-EM == destination1@gmail.com R=smarthost T=remote_smtp_smarthost defer (-53): retry time not reached for any host
2018-10-27 17:32:47 1gGSHC-0002is-0H == destination1@gmail.com R=smarthost T=remote_smtp_smarthost defer (-53): retry time not reached for any host
2018-10-27 17:32:47 End queue run: pid=12074
2018-10-27 17:32:53 1gGSQA-00038q-A1 H=smtpauth-dc2.online.net [62.210.16.40] Connection timed out
2018-10-27 17:32:53 1gGSQA-00038q-A1 == destination1@gmail.com R=smarthost T=remote_smtp_smarthost defer (110): Connection timed out

2018-10-27 17:47:12 1gGSg4-00039P-CW <= root@localhost U=root P=local S=369
2018-10-27 17:47:12 1gGSg4-00039P-CW == destination2@yahoo.com R=smarthost T=remote_smtp_smarthost defer (-53): retry time not reached for any host


2018-10-27 18:02:34 1gGSst-0003JZ-5k H=smtp.free.fr [212.27.48.4] Connection timed out
2018-10-27 18:02:34 1gGSst-0003JZ-5k == destination2@yahoo.com R=smarthost T=remote_smtp_smarthost defer (110): Connection timed out
2018-10-27 18:03:09 1gGSvV-0003KT-9k <= root@localhost U=root P=local S=369
2018-10-27 18:03:09 1gGSvV-0003KT-9k == destination2@yahoo.com R=smarthost T=remote_smtp_smarthost defer (-53): retry time not reached for any host

我在配置中遺漏了什麼嗎?

預設情況下,Scaleway 會阻止傳出 SMTP。您需要從控制面板中取消阻止它。訪問此選項需要經過驗證的帳戶;如果您無法啟用它,請使用 Scaleway 開具工單以獲取進一步說明。

引用自:https://serverfault.com/questions/937526