Postfix:本地通过端口 465/587 发送外发邮件

Postfix:本地通过端口 465/587 发送外发邮件

我已经使用 postfix、dovecot、opendkim 和 spamassassin 设置了邮件服务器。经过一番麻烦之后,我设法让收到的邮件正常工作——我什至使用该服务器设置了这个帐户。

但是,我在发送邮件时遇到了问题。我的 ISP,尽管很胖,却阻止了通过端口 25 的通信...这意味着,显然,发送消息不起作用。以下是尝试发送到我的旧 Protonmail 帐户(从外部计算机上的 Neomutt)后的日志:

postfix/qmgr[653083]: 7E2BD9006AB: from=<[email protected]>, size=479, nrcpt=1 (queue active)
// disconnect from external client
postfix/smtp[653086]: connect to mail.protonmail.ch[185.70.41.101]:25: Connection timed out
postfix/smtp[653093]: connect to mail.protonmail.ch[185.70.41.101]:25: Connection timed out
postfix/smtp[653086]: connect to mailsec.protonmail.ch[185.70.40.102]:25: Connection timed out
postfix/smtp[653086]: 44DED90068A: to=<[email protected]>, relay=none, delay=115, delays=55/0.05/60/0, dsn=4.4.1, status=deferred (connect to mailsec.protonmail.ch[185.70.40.102]:25: Connection timed out)

所以,是的... ISP 阻止端口 25(传出),所以我需要一种方法来绕过它。我见过很多的一种方法是配置使用外部 smtpd。我要么必须使用我的 ISP(不理想),要么在我朋友的 VPS 上设置 postfix(也不完全理想,但如果其他方法都失败了,我会问他)。从技术上讲,我可以要求我的 ISP 解锁端口 25,但这可能行不通。

但是,我想将所有外发邮件路由到外部服务器的端口 465 或 587,不是25,仅使用我的本地后缀设置。我在网上找不到任何有关此内容的信息,并且将传出 smtp 端口更改为备用端口仍然master.cf通过 25 发送内容。那么,我应该如何执行此操作?请记住,如果我真的无能为力,那么我可以向我的朋友索要他的 VPS

postconf -n:

alias_database = $alias_maps
alias_maps = hash:/etc/postfix/aliases
command_directory = /usr/bin
compatibility_level = 3.6
daemon_directory = /usr/lib/postfix/bin
data_directory = /var/lib/postfix
debug_peer_level = 2
debugger_command = PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin ddd $daemon_directory/$process_name $process_id & sleep 5
home_mailbox = Mail/Inbox/
html_directory = no
inet_protocols = ipv4
mail_owner = postfix
mailbox_command = /usr/lib/dovecot/deliver
mailq_path = /usr/bin/mailq
manpage_directory = /usr/share/man
meta_directory = /etc/postfix
milter_default_action = accept
milter_protocol = 6
mydestination = $myhostname $mydomain localhost localhost.localdomain
mydomain = doma.in
myhostname = mail.doma.in
mynetworks = 127.0.0.0/8 [::1]/128 MY.IP/32 192.168.86.1 192.168.86.0/24
newaliases_path = /usr/bin/newaliases
non_smtpd_milters = inet:127.0.0.1:12301
queue_directory = /var/spool/postfix
readme_directory = /usr/share/doc/postfix
relay_domains = $mydestination
sample_directory = /etc/postfix
sendmail_path = /usr/bin/sendmail
setgid_group = postdrop
shlib_directory = /usr/lib/postfix
smtp_tls_CAfile = /etc/letsencrypt/live/doma.in/cert.pem
smtp_tls_loglevel = 1
smtp_tls_mandatory_protocols = !SSLv2, !SSLv3, !TLSv1, !TLSv1.1
smtp_tls_protocols = !SSLv2, !SSLv3, !TLSv1, !TLSv1.1
smtp_tls_security_level = may
smtpd_milters = inet:127.0.0.1:12301
smtpd_recipient_restrictions = permit_sasl_authenticated, permit_mynetworks, reject_unauth_destination
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated reject_unauth_destination
smtpd_sasl_auth_enable = yes
smtpd_sasl_path = private/auth
smtpd_sasl_security_options = noanonymous
smtpd_sasl_tls_security_options = noanonymous
smtpd_sasl_type = dovecot
smtpd_tls_auth_only = yes
smtpd_tls_cert_file = /etc/letsencrypt/live/doma.in/fullchain.pem
smtpd_tls_exclude_ciphers = aNULL, LOW, EXP, MEDIUM, ADH, AECDH, MD5, DSS, ECDSA, CAMELLIA128, 3DES, CAMELLIA256, RSA+AES, eNULL
smtpd_tls_key_file = /etc/letsencrypt/live/doma.in/privkey.pem
smtpd_tls_mandatory_protocols = !SSLv2, !SSLv3, !TLSv1, !TLSv1.1
smtpd_tls_protocols = !SSLv2, !SSLv3, !TLSv1, !TLSv1.1
smtpd_tls_security_level = may
tls_preempt_cipherlist = yes
unknown_local_recipient_rject_code = 550

答案1

您可以将端口 587 用于:

postconf -ev relayhost=smtp.example.com:submission

使用端口 587 时,中继主机很可能需要身份验证,在这种情况下,您需要在 file 中指定所需的用户名和密码/etc/postfix/sasl_passwd

如果所选中继主机的 DNS 名称不是其主要名称(即dig -x <ip-address-of-relay-host>返回中继主机的其他名称),那么您可以通过将中继主机的名称放在括号中并添加引号来保护规范名称检查。外壳中的括号:

postconf -ev "relayhost=[smtp.example.com]:submission"

答案2

我要求ISP解封25端口,不幸的是,公司高层根本不让用户使用该端口,所以无法解封。

因此,我忍痛买了一台 VPS,效果非常好。事实证明,除了邮件之外,它对很多东西都很有用,例如 VPN、用于要求更高的服务器任务的快速 CPU(例如 Matrix 家庭服务器)等。

不幸的是我从未设法找出如何使 postfix 表现得像这样。如果有人知道如何做,请务必回答。

对于 ISP 阻止端口 25 的任何人,请考虑投资 VPS 或切换 ISP。

答案3

编辑文件 /etc/services 将端口 25 更改为 587,保存并重新启动服务 postfix。 Postfix 将停止侦听端口 25 并切换到 587,我不知道这是否会成为问题,但这是一个解决方案。

相关内容