使用服务器 proxmox1 上的 postifx 从服务器 p1 发送电子邮件

使用服务器 proxmox1 上的 postifx 从服务器 p1 发送电子邮件

我已将服务器 proxmox1 配置为通过 GMail 服务器发送电子邮件。以下是我的 /etc/postfix/main.cf 的相关部分:

smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = proxmox1
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
mydestination = $myhostname, localhost.$mydomain, localhost
# p1 has an IP in the range 192.168.1.0/24
mynetworks = 127.0.0.0/8 192.168.1.0/24
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all

inet_protocols = ipv4
relayhost = [smtp.gmail.com]:587
smtp_use_tls = yes
smtp_sasl_auth_enable = yes
smtp_tls_security_level = encrypt
smtp_sasl_password_maps = hash:/etc/postfix/sasl/sasl_passwd
smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
smtp_sasl_security_options = noanonymous

我尝试使用 mailx 和 proxmox1 上的 postfix 服务器从服务器 p1 发送电子邮件。这是我的 .mailrc 文件:

set smtp=smtp://proxmox1
set from="[email protected](p1)"

以下是我使用的命令:

echo "Test message" | mailx -s "important mail" [email protected]

失败的原因是 proxmox1 上的 postfix 尝试通过端口 25 连接到各种 google 邮件服务器(proxmox1 上的 /var/log/mail.log):

Apr 22 11:45:00 p1 postfix/smtp[6888]: connect to aspmx.l.google.com[142.250.27.26]:25: Connection timed out
Apr 22 11:45:30 p1 postfix/smtp[6888]: connect to alt2.aspmx.l.google.com[142.250.150.27]:25: Connection timed out
Apr 22 11:45:30 p1 postfix/smtp[6888]: connect to alt1.aspmx.l.google.com[2a00:1450:4025:c03::1a]:25: Cannot assign requested address
Apr 22 11:45:30 p1 postfix/smtp[6888]: connect to alt2.aspmx.l.google.com[2a00:1450:4010:c1c::1b]:25: Cannot assign requested address
Apr 22 11:45:30 p1 postfix/smtp[6888]: D331827596: to=<[email protected]>, relay=none, delay=179091, delays=179031/0.01/60/0, dsn=4.4.1, status=deferred (connect to alt2.aspmx.l.google.com[2a00:1450:4010:c1c::1b]:25: Cannot assign requested address)

proxmox1 上的相同命令给出不同的日志:

Apr 22 12:03:38 proxmox1 postfix/pickup[280663]: 87E1211695: uid=0 from=<root>
Apr 22 12:03:38 proxmox1 postfix/cleanup[340498]: 87E1211695: message-id=<20230422100338.87E1211695@A>
Apr 22 12:03:38 proxmox1 postfix/qmgr[280664]: 87E1211695: from=<root@A>, size=420, nrcpt=1 (queue active)
Apr 22 12:03:40 proxmox1 postfix/smtp[340500]: 87E1211695: to=<[email protected]>, relay=smtp.gmail.com[142.250.102.109]:587, delay=2.2, delays=0.1/0.11/0.75/1.2, dsn=2.0.0, status=sent (250 2.0.0 OK  1682157820 u13-20020a170906c40d00b0094aa087578csm3131703ejz.171 - gsmtp)
Apr 22 12:03:40 proxmox1 postfix/qmgr[280664]: 87E1211695: removed

看起来relay_host从 p1 发送电子邮件时该选项被忽略了……

任何想法 ?

马克

相关内容