Postfix, Dovecot, SquirrelMail – Fix Sending but Not Receiving Emails

dovecotpostfixsquirrelmail

I have setup a mail server using this guide: https://www.ostechnix.com/setup-mail-server-using-postfixdovecotsquirrelmail-in-centosrhelscientific-linux-6-3-step-by-step/

The webmail allows to send emails between own users i.e. in local machine and to the other servers like gmail. But it cannot receive emails from outside world. Here is what I have in /etc/postfix/main.cf:

alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
command_directory = /usr/sbin
compatibility_level = 2
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
debug_peer_level = 2
debugger_command = PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin ddd $daemon_directory/$process_name $process_id & sleep 5
home_mailbox = Maildir/
html_directory = no
inet_interfaces = localhost
inet_protocols = all
mail_owner = postfix
mailq_path = /usr/bin/mailq.postfix
manpage_directory = /usr/share/man
meta_directory = /etc/postfix
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
mydomain = domain.com
myhostname = mail.domain.com
mynetworks = 192.168.0.0/24, 127.0.0.0/8, [::1]/128
myorigin = $mydomain
newaliases_path = /usr/bin/newaliases.postfix
queue_directory = /var/spool/postfix
readme_directory = /usr/share/doc/postfix/README_FILES
sample_directory = /usr/share/doc/postfix/samples
sendmail_path = /usr/sbin/sendmail.postfix
setgid_group = postdrop
shlib_directory = /usr/lib64/postfix
unknown_local_recipient_reject_code = 550

Mydomain and myhostname is fake though. Also our ISP shouldn't block any inbound SMTP connections on port 25, but we have to double check that in a meantime. Please, advise!

Update 14/11/2017:
Enabled firewalld service once again and opened the mentioned ports. Now this error appears when trying to send an email on squirrelmail:
Connection refused 111 Can't open SMTP stream.
Please help

Best Answer

The directive:

inet_interfaces = localhost

restricts Postfix to receiving mails on localhost. Try setting that to

inet_interfaces = all

to actually accept incoming connections from the internet as well.

(And rather than completely disabling the firewall as in that recipe, open TCP port 25 (SMTP), 143 (IMAP) and 80/443 (HTTP/HTTPS) in your firewall and keep it enabled.)