how to disable port 587 and 143 in mailserver
After you install a mailserver, for instance postfix + dovecot as mail software, generally you have port 143 and 587 open for accepting plaintext requests from clients.
But plaintext requests on port 143 and 587 are not secure. You should disable them and use port 993 and 465 instead.
- port 143 - plaintext imap, not secure
- port 993 - ssl imap
- port 587 - plaintext submission, not secure, but you can force to use tls on this port
- port 465 - ssl smtp
To disable 143, just set the port to zero in "/etc/dovecot/conf.d/10-master.conf" as follows.
service imap-login {
inet_listener imap {
port = 0
}
inet_listener imaps {
port = 993
ssl = yes
}
To disable 587, comment out the submission section in "/etc/postfix/master.cf" as follows.
#submission inet n - y - - smtpd
# -o smtpd_sasl_auth_enable=yes
But then since you disabled submission, you should open smtps service in the config file above.
smtps inet n - y - - smtpd
-o syslog_name=postfix/smtps
-o smtpd_tls_wrappermode=yes
-o smtpd_sasl_auth_enable=yes
-o smtpd_reject_unlisted_recipient=no
-o smtpd_client_restrictions=$mua_client_restrictions
-o smtpd_helo_restrictions=$mua_helo_restrictions
-o smtpd_sender_restrictions=$mua_sender_restrictions
-o smtpd_recipient_restrictions=
-o smtpd_relay_restrictions=permit_sasl_authenticated,reject
-o milter_macro_daemon_name=ORIGINATING
Then restart postfix + dovecot, it will work.