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: commercial@something.io
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" externalname@outlook.com
$ mailq
8318C43C73 447 Sun Nov 26 16:29:01 commercial@something.c.intense-emblem-XXXXXX.internal
(connect to mx2.hotmail.com[65.55.37.104]:25: Connection timed out)
externalname@outlook.com
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
Best Answer
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 port587
or465
(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.