Page 1 of 1

Problems setting up email server

Posted: 2020/12/28 17:48:53
by wp.rauchholz
I am setting up an email server on my home box with postfix and dovecot
My server is modem router and has as such an internal and external network interface

From my laptop (LAN)
From Thunderbird I get the message: Could not connect to server localhost. The connection was refused.
Testing with telnet from CLI I get
(1) telnet home smtp
Trying 10.5.2.1...
telnet: connect to address 10.5.2.1: Connection refused
(2) telnet home imap
Trying 10.5.2.1...
Connected to home.
Escape character is '^]'.
* OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE STARTTLS AUTH=PLAIN AUTH=LOGIN] Dovecot ready.

Testing form server works fine.
telnet localhost imap
* OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE STARTTLS AUTH=PLAIN AUTH=LOGIN] Dovecot ready.

telnet localhost smtp
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 home.wo-lar.com ESMTP

The server is listening on port 25 and 465
lsof -i :25
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
master 3777 root 13u IPv4 738295 0t0 TCP localhost:smtp (LISTEN)
lsof -i :465
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
master 3777 root 20u IPv4 740353 0t0 TCP localhost:urd (LISTEN)

I can send mails to my gmail account. But when responding to this mail I get nothing back, not even an error message in gmail (might come later?
I opened the firewall ports too:


Extract from my firewall.

### Allow all Internal traffic to Server
iptables -A INPUT -i $INT_DEV -s $INT_NET -d $INT_NET -j ACCEPT
iptables -A OUTPUT -o $INT_DEV -s $INT_NET -d $INT_NET -j ACCEPT

# New Connection: SMTP and SMTPS (over TLS/SSL)
iptables -A INPUT -i $EXT_DEV -m state --state NEW -m tcp -p tcp --syn --dport 25 -j ACCEPT
iptables -A INPUT -i $EXT_DEV -m state --state NEW -m tcp -p tcp --syn --dport 465 -j ACCEPT

# New Connection: IMAP Email Clients (over SSL and non-encrypted)
iptables -A INPUT -i $EXT_DEV -m state --state NEW -m tcp -p tcp --dport 993 -j ACCEPT
iptables -A INPUT -i $EXT_DEV -m state --state NEW -m tcp -p tcp --syn --dport 143 -j ACCEPT

# Submission
iptables -A INPUT -i $EXT_DEV -m state --state NEW -m tcp -p tcp --dport 587 -j ACCEPT

Any help to solve this issue is welcome.

Thank you

Wolfgang

Re: Problems setting up email server

Posted: 2020/12/29 01:25:02
by Whoever
wp.rauchholz wrote:
2020/12/28 17:48:53
I am setting up an email server on my home box with postfix and dovecot
My server is modem router and has as such an internal and external network interface

lsof -i :25
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
master 3777 root 13u IPv4 738295 0t0 TCP localhost:smtp (LISTEN)
lsof -i :465
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
master 3777 root 20u IPv4 740353 0t0 TCP localhost:urd (LISTEN)
It looks like Postfix is only listening on the "lo" interface. You need to look at your master.cf file.

Re: Problems setting up email server

Posted: 2020/12/29 12:42:08
by wp.rauchholz
Thank you for responding. I looked into the master.cf file.
I understand that the following line tells postfix to listen on port 25:
# ==========================================================================
# service type private unpriv chroot wakeup maxproc command + args
# (yes) (yes) (yes) (never) (100)
# ==========================================================================
smtp inet n - n - - smtpd


When on the server I checked that postfix listens on port 25:
[root@home postfix]# telnet localhost 25
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 home.wo-lar.com ESMTP

[root@home postfix]# netstat -plutn | grep 25
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 20315/smtpd

I must be something different.
Any ideas?
Thanks
Wolfgang

Re: Problems setting up email server

Posted: 2020/12/29 12:49:47
by TrevorH
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 20315/smtpd
So it's only listening on localhost (127.0.0.1) and you need to change it to listen on another interface. Look in /etc/postfix/main.cf for the inet_interfaces = line. There are commented examples of how it should look for other than localhost.

Re: Problems setting up email server

Posted: 2020/12/29 14:15:30
by wp.rauchholz
Brilliant! Thank you very much

Kind regards,

WOlfgang