Naar inhoud springen

Postmap for relaying mails

Uit VanderSchaft

To configure Postfix to use a relay password, create a sasl_passwd file, hash it with postmap, and set permissions. Use [smtp.example.com]:587 username:password in /etc/postfix/sasl_passwd, then run:

sudo postmap /etc/postfix/sasl_passwd
sudo chown root:root /etc/postfix/sasl_passwd*
sudo chmod 0600 /etc/postfix/sasl_passwd*. 

Steps to Configure Postfix Relay Password:

Create/Edit Password File: Create a file named /etc/postfix/sasl_passwd and add your relay server credentials:


   sudo nano /etc/postfix/sasl_passwd

Add the following line, replacing with your relay server's address, port, username, and password:


   [smtp.provider.com]:587  username@domain.com:password

Generate Hash Database: Run postmap to convert the text file into a format Postfix can read:


   sudo postmap /etc/postfix/sasl_passwd

This creates a sasl_passwd.db file in the same directory. Secure the File: Because this file contains plaintext credentials, restrict access to only the root user:


   sudo chown root:root /etc/postfix/sasl_passwd /etc/postfix/sasl_passwd.db
   sudo chmod 0600 /etc/postfix/sasl_passwd /etc/postfix/sasl_passwd.db

Configure Main.cf: Ensure your /etc/postfix/main.cf is configured to use the password file:


   smtp_sasl_auth_enable = yes
   smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
   smtp_sasl_security_options = noanonymous
   smtp_use_tls = yes
   relayhost = [smtp.provider.com]:587

Restart Postfix: Reload Postfix to apply the changes

   sudo systemctl restart postfix