Postfix - can't recieve emails from external domain

February 17, 2019 233 views
Networking Email

Hello!

I have a bit common problem, but I haven’t found any solution yet, after reading really a lot of forums and tutorials. Shortly: I want to send an email from external domain to my server, but it’s never recieved.

Server:

VPS with Ubuntu 16.04.

Followed tutorial:

https://www.digitalocean.com/communi…n-ubuntu-16-04 (and a lot of others after detecting problems, but that one was the main)

What I have / can do:

What I don’t have / can’t do:

  • Any error logs in mail.log, syslog
  • Recieve email from any external domain (i.e. gmail.com)

What I try to do (but I can’t):

  • Send email from external domain (i.e. gmail.com) and recieve it in my Maildir in example.com domain

Postfix main.cf

# Debian specific:  Specifying a file name will cause the first
# line of that file to be used as the name.  The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname

smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no

# appending .domain is the MUA's job.
append_dot_mydomain = no

# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h

readme_directory = no

myhostname = vps_name
mydomain = example.com
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 my_server_ip_address
mydestination = $myhostname, localhost, localhost.$mydomain, $mydomain

# TLS parameters
#smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
#smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key

smtpd_tls_cert_file=/etc/letsencrypt/live/example.com/fullchain.pem
smtpd_tls_key_file=/etc/letsencrypt/live/example.com/privkey.pem

#smtpd_use_tls=yes
smtp_tls_security_level = may
smtpd_tls_security_level = may
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

#smtpd_tls_mandatory_protocols = !SSLv2,!SSLv3
#smtpd_tls_protocols=!SSLv2

# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.

smtpd_sender_restrictions = permit_sasl_authenticated
smtpd_relay_restrictions = 
    permit_mynetworks 
    permit_sasl_authenticated 
    permit_inet_interfaces 
    reject_unauth_destination
smtpd_recipient_restrictions =
    permit_mynetworks 
    permit_sasl_authenticated
    permit_inet_interfaces
    reject_unauth_destination

alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases

relayhost = 

mailbox_command = 
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = all
myorigin = /etc/mailname

milter_protocol = 2
milter_default_action = accept

smtpd_milters = inet:localhost:12301
non_smtpd_milters = inet:localhost:12301
home_mailbox = Maildir/

virtual_alias_maps = hash:/etc/postfix/virtual

Port 25 listening:

tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN 32022/master
tcp6 0 0 :::25 :::* LISTEN 32022/master

Additional info

When I’ll try to send email to my domain, I have non-delivery message:

Remote host said: 454 4.7.1 <admin@my_domain>: Relay access denied

If I’ll use mxtoolbox - ‘test email server’, the response is:

Connecting to MY_VPS_IP

220 VPS_NAME ESMTP Postfix (Ubuntu) [1126 ms]
EHLO keeper-us-east-1b.mxtoolbox.com
250-VPS_NAME 
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-STARTTLS
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN [705 ms]
MAIL FROM:<supertool@mxtoolbox.com>
250 2.1.0 Ok [687 ms]
RCPT TO:<test@mxtoolboxsmtpdiag.com>
554 5.7.1 <test@mxtoolboxsmtpdiag.com>: Relay access denied [690 ms]

LookupServer 8529ms

I spent a lot of hours trying to solve this problem and I failed. I will be very grateful for any advice what I’m doing wrong and how I can fix the problem.

Be the first one to answer this question.