ryankr1
By:
ryankr1

Postfix mail server not receiving mail from external domains

March 15, 2017 2.5k views
DigitalOcean Ubuntu 16.04

I can receive emails that are sent from the server locally, but if I address my server from something like gmail, nothing comes through.

The main.cf file looks like the following:

# See /usr/share/postfix/main.cf.dist for a commented, more complete version


# 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

# 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_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

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

smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = skytracker.co
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = $myhostname, skytracker.co, localhost.co, , localhost
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = all

# Milter configuration
# OpenDKIM
milter_default_action = accept
milter_protocol = 2
smtpd_milters = local:/opendkim/opendkim.sock
non_smtpd_milters = local:/opendkim/opendkim.sock

Any thoughts are greatly appreciated!

14 comments
  • Have you created MX-records for your domain? Looking at skytracker.co I'm not seeing any MX-records.

  • @hansen Yeah there are MX records. If you do the following command in the terminal you should see them:

    dig skytracker.co mx
    
  • @ryankr1 There is a response now, but there wasn't one earlier when I tested.
    A little strange. When did you add the MX?
    I'm getting this error, when trying to connect: 550 Denied by policy

    Please run this command: postconf -d | egrep "^my"
    And paste the results here.

  • @hansen I added the MX records like a while ago, couple of weeks maybe.

    I just ran your command and got the following:

    mydestination = $myhostname, localhost.$mydomain, localhost
    mydomain = co
    myhostname = skytracker.co
    mynetworks = 127.0.0.0/8 178.62.64.0/18 10.16.0.0/16 [::1]/128 [fe80::]/64
    mynetworks_style = ${{$compatibility_level} < {2} ? {subnet} : {host}}
    myorigin = $myhostname
    

    The mydomain seems wrong, but I'm not sure. Thoughts? Thanks!

  • @ryankr1
    Okay, your mydomain is wrong. It should be mydomain = skytracker.co
    That should fix it, so you can receive mails from the outside to your domain.

  • @hansen Yeah it did seem strange to just take the value co. I'll update and get back to you :)

  • @hansen I added

    mydomain = skytracker.co
    

    to /etc/postfix/main.cf , but postconf -d | egrep "^my" returns the same result. Is there some way to manually propagate this, or am I supposed to be defining it somewhere else?

  • mydomain is based on myhostname, which in a sense is also wrong, since it's only a domain.
    A host name is the computers name. So I have a server called Maria, which would be myhostname = maria.skytracker.co and then it would generate mydomain = skytracker.co
    You would then make sure there's an A-record pointing to your hostname.

  • @hansen So my server is called "skytracker.co". I did this thinking it was what was necessary for DigitalOcean to generate the PTR records for my domain. I'm not really sure what to do now to fix this problem :/

  • @ryankr1 Just set myhostname = mail.skytracker.co and work with that.

  • @hansen So I set the server name to mail.skytracker.co. Then myhostname in postfix. mydomain is then skytracker.co. Would there be any other consequences of changing the name?

  • @ryankr1 It depends on SPF, DKIM and such. But no, it shouldn't be a problem.
    EDIT: Just remember to create an A-record in the DNS for mail.skytracker.co pointing to the server.

  • @hansen Would the MX records have to change to mail.skytracker.co as opposed to skytracker.co ?

  • @ryankr1 No, you don't need to do that, since it's the same server IP, but it would be the correct way to do it.

1 Answer

so how did you fix the issue mate?

Have another answer? Share your knowledge.