Postfix Submission Service

 Published on 16 Feb 2025 .  Filed in Projects .  488 words

End users should not use port 25 but rather the submission service on TCP port 587 (as described in RFC 4409). The idea is to use port 25 to transport emails through the Mail Transport Agent (MTA) from one server to server and port 587 to submit emails through the Mail Submission Agent (MSA) from a user to a mail server.

In order to enable the submission port, we need to edit the file /etc/postfix/master.cf where all Postfix services are declared. Edit this file and find the submission section which is commented out by default. Transform this section into the following. Basically, I removed the # character on all lines in this section and removed the lines with the mua_* variables:

submission inet n       -       y       -       -       smtpd
  -o syslog_name=postfix/submission
  -o smtpd_tls_security_level=encrypt
  -o smtpd_sasl_auth_enable=yes
  -o smtpd_tls_auth_only=yes
  -o smtpd_reject_unlisted_recipient=no
  -o smtpd_client_restrictions=
  -o smtpd_helo_restrictions=
  -o smtpd_sender_restrictions=
  -o smtpd_relay_restrictions=
  -o smtpd_recipient_restrictions=permit_sasl_authenticated,reject
  -o milter_macro_daemon_name=ORIGINATING

CAREFUL: Make sure to start the first line in the first column and indent the following lines.

Restart the Postfix server:

  systemctl restart postfix

Test Submission Service

Your users can now use the submission port to send email. They just use the port 587 in their mail clients instead of port 25. You will need to install the libnet-ssleay-perl package first to use TLS encryption in SWAKS:

  sudo apt install -y libnet-ssleay-perl

Send a mails on submission port 587:

  swaks --server localhost --to user1@example1.com --port 587 -tls --auth-user user1@example1.com --auth-password SecurePass

NOTE: What is Port 465 ? This TCP port belongs to the "submission over TLS" service. It is used for the submission service but expects an encrypted connection from the first byte. This port is hardly ever used so you don’t have to care about it. The submission service you just configured is also encrypted but uses the STARTTLS mechanism to switch to a TLS connection after the welcome message.