Postfix 不向自己的域发送邮件

Postfix 不向自己的域发送邮件

我遇到一个问题,ubuntu 18.04 上的 kopano / postfix 无法向我自己的域发送邮件。

我的域名例如:example.com

我尝试发送一封邮件[电子邮件保护][电子邮件保护] 出现以下错误:

Jun 21 13:25:32 exchange postfix/qmgr[13899]: C30943A15A3: from=<not- 
[email protected]>, size=3784, nrcpt=1 (queue active)
Jun 21 13:25:32 exchange amavis[3249]: (03249-05) Passed CLEAN     {RelayedInbound}, [xxx.xxx.xxx.xxx]:63079 [xxx.xxx.xxx.xxx] <not-    [email protected]> -> <[email protected]>, Queue-ID: 456423A142E, Message-ID:     <[email protected]>, mail_id: zhlvJZ3aV8GE, Hits: 2.2,     size: 2952, queued_as: C30943A15A3, 1507 ms
Jun 21 13:25:32 exchange postfix/lmtp[16290]: connect to example.com[xxx.xxx.xxx.xx]:24: Connection refused
Jun 21 13:25:32 exchange postfix/lmtp[16290]: C30943A15A3: to=    <[email protected]>, relay=none, delay=0.01,     delays=0/0/0/0, dsn=4.4.1, status=deferred (connect to example.com[xxx.xxx.xxx.xxx]:24: Connection refused)
Jun 21 13:25:33 exchange postfix/smtps/smtpd[14561]: disconnect from     unknown[xxx.xxx.xxx.xxx] ehlo=1 auth=1 mail=1 rcpt=1 data=1 quit=1 commands=6

这是 postconf -n 的输出

root@exchange:~# postconf -n
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
append_dot_mydomain = no
biff = no
bounce_queue_lifetime = 10m
broken_sasl_auth_clients = yes
compatibility_level = 2
content_filter = smtp-amavis:[127.0.0.1]:10024
disable_vrfy_command = yes
inet_interfaces = all
inet_protocols = ipv4
mailbox_size_limit = 0
maximal_queue_lifetime = 10m
message_size_limit = 10240000
mydestination = localhost
myhostname = exchange.example.com
mynetworks = 127.0.0.0/8
myorigin = exchange.example.com
readme_directory = no
recipient_delimiter = +
smtp_bind_address = xxx.xxx.xxx.xxx
smtp_tls_mandatory_protocols = !SSLv2, !SSLv3
smtp_tls_protocols = !SSLv2, !SSLv3
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_banner = $myhostname ESMTP
smtpd_client_restrictions = permit_sasl_authenticated, reject
smtpd_delay_reject = yes
smtpd_helo_required = yes
smtpd_proxy_timeout = 3600s
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated,         reject_unauth_destination, reject_non_fqdn_sender
smtpd_relay_restrictions = permit_mynetworks, permit_sasl_authenticated,     reject_unauth_destination
smtpd_sasl_auth_enable = yes
smtpd_sasl_path = smtpd
smtpd_sasl_security_options = noanonymous
smtpd_sender_restrictions = permit_sasl_authenticated
smtpd_timeout = 3600s
smtpd_tls_cert_file = /etc/ssl/certs/mailcert.pem
smtpd_tls_key_file = /etc/ssl/private/mailcert.key
smtpd_tls_loglevel = 1
smtpd_tls_mandatory_protocols = !SSLv2, !SSLv3
smtpd_tls_protocols = !SSLv2, !SSLv3
smtpd_tls_security_level = may
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtpd_use_tls = yes
strict_rfc821_envelopes = yes
virtual_alias_maps = hash:/etc/postfix/virtual
virtual_mailbox_domains = example.com
virtual_mailbox_limit = 0
virtual_mailbox_maps = mysql:/etc/postfix/mysql-users.cf
virtual_transport = lmtp

这是 postconf -M 的输出

root@exchange:~# postconf -M
smtps      inet  n       -       y       -       -       smtpd -o     syslog_name=postfix/smtps -o smtpd_tls_wrappermode=yes -o     smtpd_sasl_auth_enable=yes -o smtpd_reject_unlisted_recipient=no -o     smtpd_client_restrictions=permit_sasl_authenticated,reject -o     smtpd_recipient_restrictions=permit_sasl_authenticated,reject -o     smtpd_relay_restrictions=permit_sasl_authenticated,reject -o     milter_macro_daemon_name=ORIGINATING
pickup     unix  n       -       y       60      1       pickup
cleanup    unix  n       -       y       -       0       cleanup
qmgr       unix  n       -       n       300     1       qmgr
tlsmgr     unix  -       -       y       1000?   1       tlsmgr
rewrite    unix  -       -       y       -       -       trivial-rewrite
bounce     unix  -       -       y       -       0       bounce
defer      unix  -       -       y       -       0       bounce
trace      unix  -       -       y       -       0       bounce
verify     unix  -       -       y       -       1       verify
flush      unix  n       -       y       1000?   0       flush
proxymap   unix  -       -       n       -       -       proxymap
proxywrite unix  -       -       n       -       1       proxymap
smtp       unix  -       -       y       -       -       smtp
relay      unix  -       -       y       -       -       smtp -o     syslog_name=postfix/$service_name
showq      unix  n       -       y       -       -       showq
error      unix  -       -       y       -       -       error
retry      unix  -       -       y       -       -       error
discard    unix  -       -       y       -       -       discard
local      unix  -       n       n       -       -       local
virtual    unix  -       n       n       -       -       virtual
lmtp       unix  -       -       y       -       -       lmtp
anvil      unix  -       -       y       -       1       anvil
scache     unix  -       -       y       -       1       scache
maildrop   unix  -       n       n       -       -       pipe flags=DRhu     user=vmail argv=/usr/bin/maildrop -d ${recipient}
uucp       unix  -       n       n       -       -       pipe flags=Fqhu     user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail ($recipient)
ifmail     unix  -       n       n       -       -       pipe flags=F     user=ftn argv=/usr/lib/ifmail/ifmail -r $nexthop ($recipient)
bsmtp      unix  -       n       n       -       -       pipe flags=Fq.     user=bsmtp argv=/usr/lib/bsmtp/bsmtp -t$nexthop -f$sender $recipient
scalemail-backend unix - n       n       -       2       pipe flags=R     user=scalemail argv=/usr/lib/scalemail/bin/scalemail-store ${nexthop} ${user}     ${extension}
mailman    unix  -       n       n       -       -       pipe flags=FR     user=list argv=/usr/lib/mailman/bin/postfix-to-mailman.py ${nexthop} ${user}
smtp-amavis unix -       -       -       -       2       smtp -o     smtp_data_done_timeout=1200 -o smtp_send_xforward_command=yes -o     disable_dns_lookups=yes -o max_use=20
127.0.0.1:10025 inet n   -       -       -       -       smtpd -o     content_filter= -o local_recipient_maps= -o relay_recipient_maps= -o     smtpd_restriction_classes= -o smtpd_delay_reject=no -o     smtpd_client_restrictions=permit_mynetworks,reject -o smtpd_helo_restrictions= -    o smtpd_sender_restrictions= -o     smtpd_recipient_restrictions=permit_mynetworks,reject -o     smtpd_data_restrictions=reject_unauth_pipelining -o     smtpd_end_of_data_restrictions= -o mynetworks=127.0.0.0/8 -o     smtpd_error_sleep_time=0 -o smtpd_soft_error_limit=1001 -o     smtpd_hard_error_limit=1000 -o smtpd_client_connection_count_limit=0 -o     smtpd_client_connection_rate_limit=0 -o     receive_override_options=no_header_body_checks,no_unknown_recipient_checks
2003       inet  n       -       -       -       -       lmtp

答案1

我发现这些错误非常明显:

connect to localhost[127.0.0.1]:2003: Connection refused
status=deferred (connect to localhost[127.0.0.1]:2003: Connection refused)

您的对应行main.cf

virtual_transport = lmtp:[localhost]:2003

virtual_transport(默认:virtual

默认邮件投递传输和最终投递到 列出的域的下一跳目的地$virtual_mailbox_domains。此信息可以用transport(5)表格来覆盖。

指定格式transport:nexthop运输是 中定义的邮件投递传输的名称master.cf:nexthop 目标是可选的;其语法记录在相应投递代理的手册页中。

中的默认lmtp传输master.cflmtp unix - - y - - lmtp使用 UNIX 套接字而不是 TCP 端口。LMTP 的默认 TCP 端口通常为 24。如果您没有专门配置 LMTP 来监听localhost:2003,那就是错误。

我们不能肯定地说你想做什么,但可能的解决方案可能包括:

  • 添加2003 inet n - - - - lmtpmaster.cfOR
  • 删除主机名和端口,即virtual_transport = lmtp
  • 全部删除virtual_transport = lmtp:[localhost]:2003,即使用默认。

相关内容