Set password to access postfix running on macos

80 Views Asked by At

I have configured postfix to act as a relay on my Mac Laptop. I want to now enforce an authentication on postfix so that any client trying to connect on port 25 needs to authenticate first. Is this possible?

1

There are 1 best solutions below

1
Guapi-zh On

Yes, it is possible. You can use SASL to achieve this function. On Mac, install cyrus-sasl and modify the following settings in the Postfix configuration file to enable SMTP authentication and restrict relay access:

smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
smtpd_recipient_restrictions =
    permit_sasl_authenticated,
    permit_mynetworks,
    reject_unauth_destination
smtpd_sender_login_maps = hash:/etc/postfix/login_maps

You also have to create a file at /etc/postfix/login_maps and add entries for the authenticated users. This file maps email addresses to usernames and passwords. Each line should be in the format:

[email protected] password1
[email protected] password2

Then generate hashed database file using:

sudo postmap /etc/postfix/login_maps

After making these changes, restart the Postfix service to apply.