大网数据广告活动
服务器运维问答

How to config Postfix to send external mail without use Relay of Google or other

· 52CE 我爱测

I was able to configure Postfix to send external emails using Google's retransmission, but that's not what I want. I mean, I want to send mails through my own domain. The Postfix was configured and it can receive email from exter…

问题原文

原帖链接 · Marcos · CC BY-SA 3.0

I was able to configure Postfix to send external emails using Google's retransmission, but that's not what I want. I mean, I want to send mails through my own domain.

The Postfix was configured and it can receive email from externals domains.

However I'd like to send external mails without use Relay of Google or other one. How can I do it? What are the configs?

My internal email is: [email omitted]

Versions: Ubuntu 17.10 (Artful Aardvark) ; Postfix 3.2.3

Below my setups;

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:

Below my extra setups;

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}

Command to send an external mail:

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

$ mailq

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

I'd like to send external mails without use Relay of Google or other one. How can I do it? What are the configs?

Could you please check it and guide me to turn on the postfix to send externals mails through my own domain? Thanks

已采纳解答

原帖链接 · Esa Jokinen · CC BY-SA 3.0

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

This suggests that you may have nothing wrong with your configuration, but your server is on a connection that doesn't allow using port 25 for outgoing connections, which is required to send emails directly to the receiving MTA. Your former configuration with Google's re-transmission probably used submission port 587 or 465 (for TLS), instead.

This limitation is typical on lines that aren't supposed to host email servers. It's a common practice to prevent spam from infected workstations. Ask your ISP whether it's possible to remove this limitation or use submission with an intermediate MTA outside your network.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-11-27)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。