Postfix 通过另一个 Postfix 服务器进行中继

Postfix 通过另一个 Postfix 服务器进行中继

我的 LAN 上有一个使用 Virtualmin 运行的 Postfix 服务器。此服务器上共有 4 个域,我需要能够向此服务器上的域发送和接收电子邮件。

问题是我的 ISP(康卡斯特)阻止了入站和出站端口 25。

因此,我有一个远程 VPS,希望使用它来中继邮件,包括端口 587 上的入站和出站邮件。该 VPS 还在 Virtualmin 上安装了 Postfix。

所以我有四个领域:

域名.com 域名2.com 域名3.com 域名4.com

如果我发送电子邮件[电子邮件保护]我希望它通过我的外部邮件服务器(mail.domain.com,在我的 VPN 上也是 10.1.0.10)中继到目的地。同时,如果有人发送电子邮件到[电子邮件保护]我的 MX 记录将使其传送到 mail.domain.com,然后通过端口 587 和我的 VPN 进入我的网络。

我在这方面做了一些工作。我可以访问我的 VPS,但收到一些错误消息。我想我遇到了问题,无法弄清楚如何让我的 VPS 上的用户能够通过此 Postfix 服务器中继邮件以通过 SASL 身份验证。

这是我 LAN 上的 Postfix 服务器上的 main.cf:

# 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 (Debian/GNU)
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_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 = cactuar.domain.local
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = cactuar.domain.local, localhost.domain.local, , localhost
relayhost = [10.1.0.10]:587
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_command = /usr/bin/procmail-wrapper -o -a $DOMAIN -d $LOGNAME
mailbox_size_limit = 0
recipient_delimiter = +
virtual_alias_maps = hash:/etc/postfix/virtual
sender_bcc_maps = hash:/etc/postfix/bcc
home_mailbox = Maildir/
smtpd_sasl_auth_enable = yes
broken_sasl_auth_clients = yes
smtpd_recipient_restrictions = permit_mynetworks     permit_sasl_authenticated reject_unauth_destination
allow_percent_hack = no

# enable SASL authentication 
smtp_sasl_auth_enable = yes
# disallow methods that allow anonymous authentication. 
smtp_sasl_security_options = noanonymous
# where to find sasl_passwd
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
# Enable STARTTLS encryption 
smtp_use_tls = yes
# where to find CA certificates
smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt

这是我远程 mail.domain.com VPS 上的 main.cf:

# 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 (Debian/GNU)
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_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 = mail.domain.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
mydestination = $myhostname, localhost.$mydomain $mydomain
relaydomains = 
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 10.0.0.0/8
mailbox_command = /usr/bin/procmail-wrapper -o -a $DOMAIN -d $LOGNAME
mailbox_size_limit = 0
recipient_delimiter = +
virtual_alias_maps = hash:/etc/postfix/virtual
sender_bcc_maps = hash:/etc/postfix/bcc
home_mailbox = Maildir/
smtpd_sasl_auth_enable = yes
broken_sasl_auth_clients = yes
smtpd_recipient_restrictions = permit_mynetworks     permit_sasl_authenticated reject_unauth_destination
allow_percent_hack = no
transport_maps = hash:/etc/postfix/transport

# SASL SUPPORT FOR CLIENTS
#
# The following options set parameters needed by Postfix to enable
# Cyrus-SASL support for authentication of mail clients.
#
smtpd_sasl_auth_enable = yes
broken_sasl_auth_clients = yes
smtpd_sasl_local_domain = $myhostname
smtpd_recipient_restrictions = permit_mynetworks     permit_sasl_authenticated reject_unauth_destination
smtp_sasl_auth_enable = yes
myorigin = $mydomain

当我从我的家庭服务器向互联网发送电子邮件时,我收到以下 mail.log 结果:

在我的家庭服务器上:

Dec  5 12:41:02 cactuar postfix/qmgr[29509]: DEA6EC1725: from=<[email protected]>, size=655, nrcpt=1 (queue active)
Dec  5 12:41:03 cactuar dovecot: imap(domain): Connection closed in=748 out=2203
Dec  5 12:41:03 cactuar postfix/smtp[32026]: DEA6EC1725: to=<[email protected]>, relay=10.1.0.10[10.1.0.10]:587, delay=0.29, delays=0.08/0.04/0.17/0, dsn=4.7.8, status=deferred (SASL authentication failed; server 10.1.0.10[10.1.0.10] said: 535 5.7.8 Error: authentication failed: generic failure)

在我的远程 VPS 上,当有邮件来自我的家庭服务器时:

Dec  5 13:43:34 kupo postfix/smtpd[29636]: connect from unknown[10.0.0.24]
Dec  5 13:43:34 kupo postfix/smtpd[29636]: warning: SASL authentication failure: cannot connect to saslauthd server: No such file or directory
Dec  5 13:43:34 kupo postfix/smtpd[29636]: warning: SASL authentication failure: Password verification failed
Dec  5 13:43:34 kupo postfix/smtpd[29636]: warning: unknown[10.0.0.24]: SASL PLAIN authentication failed: generic failure
Dec  5 13:43:34 kupo postfix/smtpd[29636]: disconnect from unknown[10.0.0.24]

我已经使用命令在 saslauthd 中设置了一个用户saslpasswd2 -c <username>,当我连接到远程 VPS 时,我的内部服务器中就有该用户名,并且 saslauthd 在两台机器上运行。

希望有人可以指导我解决这个问题。

感谢您的任何帮助,您可以提供。

相关内容