如何配置 Postfix 发送外部邮件而不使用 Google 或其他中继

如何配置 Postfix 发送外部邮件而不使用 Google 或其他中继

我能够配置 Postfix 使用 Google 的重发功能发送外部电子邮件,但这不是我想要的。我的意思是,我想通过自己的域发送邮件。

Postfix 已配置,它可以接收来自外部域的电子邮件。

但是我想发送外部邮件而不使用 Google 或其他中继。我该怎么做?配置是什么?

我的内部电子邮件是:[电子邮件保护]

版本:Ubuntu 17.10 (Artful Aardvark);Postfix 3.2.3

以下是我的设置;

The ports 25 and 587 are open in GCP where postfix was configured

There is an linux user commercial name created where postfix was configured

MX and A DNS were setup and below you can see report yielded from dig linux command:

以下是我的额外设置;

something.io.         59      IN      MX      10 mail.something.io.

mail.something.io.    59      IN      A       <SOMETHING IP ADDRESS>

$ dig MX something.io

; <<>> DiG 9.10.3-P4-Ubuntu <<>> MX something.io
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 19811
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 65494
;; QUESTION SECTION:
;something.io.                     IN      MX

;; ANSWER SECTION:
something.io.              39      IN      MX      10 mail.something.io.

;; Query time: 0 msec
;; SERVER: 127.0.0.53#53(127.0.0.53)
;; WHEN: Mon Nov 27 09:48:15 -02 2017
;; MSG SIZE  rcvd: 59

$ dig A mail.something.io

; <<>> DiG 9.10.3-P4-Ubuntu <<>> A mail.something.io
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 9197
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 65494
;; QUESTION SECTION:
;mail.something.io.                        IN      A

;; ANSWER SECTION:
mail.something.io.         47      IN      A       35.188.104.163

;; Query time: 0 msec
;; SERVER: 127.0.0.53#53(127.0.0.53)
;; WHEN: Mon Nov 27 09:48:22 -02 2017
;; MSG SIZE  rcvd: 59

$ sudo postconf -n

alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
append_dot_mydomain = no
biff = no
compatibility_level = 2
home_mailbox = Maildir/
inet_interfaces = all
inet_protocols = all
mailbox_size_limit = 0
mydestination = $myhostname localhost.$mydomain localhost
myhostname = something.io
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
myorigin = /etc/mailname
readme_directory = no
recipient_delimiter = +
relayhost =
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
smtpd_tls_cert_file = /etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file = /etc/ssl/private/ssl-cert-snakeoil.key
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtpd_use_tls = yes
virtual_alias_maps = hash:/etc/postfix/virtual

$ sudo postconf -M

smtp       inet  n       -       y       -       -       smtpd
submission inet  n       -       y       -       -       smtpd
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
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}

发送外部邮件的命令:

echo "Body-Test" | mail -s "Subject-Test" [email protected]

$ mailq

8318C43C73      447 Sun Nov 26 16:29:01  [email protected]
           (connect to mx2.hotmail.com[65.55.37.104]:25: Connection timed out)
                                         [email protected]

我想发送外部邮件,而不使用 Google 或其他中继。我该怎么做?配置是什么?

能不能请你检查一下,并指导我打开 postfix 以通过我自己的域发送外部邮件?谢谢

答案1

(connect to mx2.hotmail.com[65.55.37.104]:25: Connection timed out)

这表明您的配置可能没有任何问题,但您的服务器所处的连接不允许使用端口25进行传出连接,而这是将电子邮件直接发送到接收 MTA 所必需的。您之前使用 Google 重新传输的配置可能使用了提交端口587465(对于 TLS)。

这种限制在不用于托管电子邮件服务器的线路上很常见。这是一种防止垃圾邮件从受感染的工作站发出的常见做法。询问您的 ISP 是否可以删除此限制或使用提交使用网络外部的中间 MTA。

相关内容