Postfix + dovecot is sending email but not receiving

Posted November 10, 2020 479 views
Ubuntu 20.04

I’ve been following a tutorial to set up a mail server (on the same server at nextcloud). The tutorial is here:

All seemed to be working as expected until it came to testing email. I can send email but I’m not receiving anything. When I send email from another device, my sending clients don’t report any issues in sending the mail, but nothing happens with postfix. /var/log/mail.log shows nothing at all when I send mail to the domain the server is set up on. (Nothing shows in syslog either).

I found this related question on this forum:

And it asks if postfix is listening on port 25 - having run the lsof command, postfix doesn’t seem to be listening on any port. So I guess that’s at least part of the issue.
My lsof output (grep for 25, dovecot, rspamd and postfix) is:

ubuntu@myserver:~$ sudo lsof -iTCP -sTCP:LISTEN -P |egrep "25|dovecot|rspamd|postfix|postgre"
postgres     727        postgres    3u  IPv4   20741      0t0  TCP localhost:5432 (LISTEN)
rspamd      1173            root    9u  IPv4   22918      0t0  TCP localhost:11332 (LISTEN)
rspamd      1173            root   11u  IPv4   22923      0t0  TCP localhost:11334 (LISTEN)
rspamd      1173            root   14u  IPv4   22928      0t0  TCP localhost:11333 (LISTEN)
rspamd    156792         _rspamd    9u  IPv4   22918      0t0  TCP localhost:11332 (LISTEN)
rspamd    156792         _rspamd   11u  IPv4   22923      0t0  TCP localhost:11334 (LISTEN)
rspamd    156792         _rspamd   14u  IPv4   22928      0t0  TCP localhost:11333 (LISTEN)
rspamd    156793         _rspamd    9u  IPv4   22918      0t0  TCP localhost:11332 (LISTEN)
rspamd    156793         _rspamd   11u  IPv4   22923      0t0  TCP localhost:11334 (LISTEN)
rspamd    156793         _rspamd   14u  IPv4   22928      0t0  TCP localhost:11333 (LISTEN)
rspamd    156794         _rspamd    9u  IPv4   22918      0t0  TCP localhost:11332 (LISTEN)
rspamd    156794         _rspamd   11u  IPv4   22923      0t0  TCP localhost:11334 (LISTEN)
rspamd    156794         _rspamd   14u  IPv4   22928      0t0  TCP localhost:11333 (LISTEN)
dovecot   158604            root   15u  IPv4 1147425      0t0  TCP *:4190 (LISTEN)
dovecot   158604            root   16u  IPv6 1147426      0t0  TCP *:4190 (LISTEN)
dovecot   158604            root   38u  IPv4 1147473      0t0  TCP *:143 (LISTEN)
dovecot   158604            root   39u  IPv6 1147474      0t0  TCP *:143 (LISTEN)
dovecot   158604            root   40u  IPv4 1147475      0t0  TCP *:993 (LISTEN)
dovecot   158604            root   41u  IPv6 1147476      0t0  TCP *:993 (LISTEN)
master    161752            root   13u  IPv4 1162695      0t0  TCP *:25 (LISTEN)
master    161752            root   14u  IPv6 1162696      0t0  TCP *:25 (LISTEN)

The relevant line from postfix/ is:

# ==========================================================================
# service type  private unpriv  chroot  wakeup  maxproc command + args
#               (yes)   (yes)   (no)    (never) (100)
# ==========================================================================
smtp      inet  n       -       y       -       -       smtpd -v

Which if I’m understanding other posts correctly means postfix should default to port 25?

Any suggestions on where to start to fix this?

edited by bobbyiliev

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
2 answers

Hi @hedgert,

Firstly, I’ll recommend using port 465 for sending out messages rather than 25. Port 25 is considered an unsecured port and more often than not providers block emails from it.

Another possibility is the IP of the Droplet is considered as a threat due to some reason.

I do believe messages are being sent but just are always deferred by the host. I’ll recommend using an e-mail checker to see what score your E-mails rank up to. The link is here - The way it works is you send a message to the given e-mail account and check the score of your message. It will provide you with a scale from 1 to 10 and notify you about any issues you might need to fix.

Try it out and see if after making a 10/10 score on the tester the messages will still be marked as spam.

One other thing, you know content does matter and it’s possibly Gmail are marking your messages based on it.


Thank you for your reply - alas (in your suggestion of using a different port) you are further on than I am with my setup! If I could get postfix working then I’ll gladly look at better ports.

This is where I’ve got to:
postfix is not listening on port 25 other than on localhost. I can telnet to localhost on the machine using port 25. But if I telnet to the IP address using port 25, then I get connection refused. (When the telnet connects on localhost, the syslog lights up with action, when I try to connect from offhost, then nothing happens on syslog.

The ubuntu ufw firewall is not active.
I have inet_interfaces=all in /etc/postfix/

But I cannot connect on port 25 (which any mail programme trying to send email to my email server will surely do - so not sure what the port change will achieve anyway once I can get it working).

Any suggestions for what else I can try?

  • Were you able to find a solution?

    I was having a similar problem. I could send to myself but not receive mail from a remote mail server such as gmail

    I knew in the past I added port 25 to the firewall (Several times)

    but what I probably did not do was ufw reload…

    So I ran ‘sudo ufw reload’ and email was streaming in to my inbox

    Run 'sudo ufw status’

    sudo ufw allow 25/tcp
    sudo ufw reload

  • Somehow I missed this reply when I was going over my answer. Anyway, I’ll suggest allowing connections on port 25.

    Allow All Incoming SMTP
    To allow your server to respond to SMTP connections, port 25, run these commands:

    sudo iptables -A INPUT -p tcp --dport 25 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT
    sudo iptables -A OUTPUT -p tcp --sport 25 -m conntrack --ctstate ESTABLISHED -j ACCEPT

    The second command, which allows the outgoing traffic of established SMTP connections, is only necessary if the OUTPUT policy is not set to ACCEPT.

    And to allow outgoing:

    iptables -A INPUT -p tcp --dport 25 -j ACCEPT
    iptables -A INPUT -p tcp --dport 465 -j ACCEPT

    I know you mentioned you’ve disabled the firewall, but unless you’ve stopped the IPtables service, it will be working.