PostFix per Username Authentication

To use an authenticated user:

  1. Add or amend the following line in /etc/postfix/main.cf:

    relayhost = demo-domain.invalid

  2. Add the following to /etc/postfix/main.cf below the relayhost = line:
    smtp_sasl_auth_enable = yes
    smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
    smtp_sasl_security_options = 
    smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
    smtp_use_tls = yes
  3. Create a password maps file /etc/postfix/sasl_passwd containing the login credentials:
  4. demo-domain.invalid USERNAME:PASSWORD

    Where demo-domain.invalid is replaced with your domain name and USERNAME:PASSWORD are replaced with the Authenticating User and it's password

  5. Update permissions on the sasl_passwd file to make it readable only by root user, and create the hash database:
    sudo chmod 600 /etc/postfix/sasl_passwd
    sudo postmap /etc/postfix/sasl_passwd
  6. Restart Postfix for the changes to take effect using

    /etc/init.d/postfix restart