0

I tryed to manage with a postfix server, my goal is that :

When 1 special user (test@example.com) try to send mail, it will use routing (using a relay server is OK) but I don't understand how to send authentification to the relay server to be authorized to send mail. I do that on my main.cf file :

relay_domains =
$mydestination
proxy:mysql:/etc/postfix/mysql/relay_domains.cf

relay_recipient_maps =
    mysql:/etc/postfix/mysql/relay_recipient_maps.cf

The first point is OK : I see that mail use relay specified into my mysql table to send mail The second point has an issue : I think user/passsword are not send to relay so my mail is refused on it. The file /etc/postfix/mysql/relay_recipient_maps.cf content is :

hosts       = 127.0.0.1:3306
user        = BDD_USER
password    = BDD_PASS
dbname      = BDD_DBNAME
query       = SELECT authentification FROM domain WHERE domain='%s' LIMIT 1

And in MySQL, "authentification" field contain user:password for relay authentification inplain text

Regards and have a good day !

PopFR1
  • 1

1 Answers1

0

To authenticate with the relay server in Postfix, you need to configure the smtp_sasl_auth_enable parameter in your main.cf file.

  1. Open your main.cf configuration file for Postfix.
  2. Add or modify the following parameters:
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
  1. Create a sasl_passwd file and specify the relay server's hostname or IP address, along with the authentication credentials:
relay.example.com    username:password
  1. Generate the hash map file from the sasl_passwd file:
sudo postmap /etc/postfix/sasl_passwd
  1. Set the correct permissions for the sasl_passwd.db file:
sudo chown root:root /etc/postfix/sasl_passwd.db
sudo chmod 0600 /etc/postfix/sasl_passwd.db
  1. Restart the postfix:
sudo service postfix restart

By configuring the smtp_sasl_auth_enable parameter and providing the authentication details in the sasl_passwd file, Postfix will use those credentials to authenticate with the relay server when sending emails.

Hawshemi
  • 302
  • 5
  • Hi, thanks for your reply. I tryed to use Mysql for that so I need to use `smtp_sasl_password_maps = mysql:/etc/postfix/sasl_passwd` ? But when I do that, it seems that the auth data are not used anymore ?! – PopFR1 May 21 '23 at 12:37
  • @PopFR1 1. `sudo apt-get install postfix-mysql` 2. Create a file like /etc/postfix/mysql_relay_passwords.cf with MySQL connection and query details. 3. In `main.cf`, set `smtp_sasl_auth_enable = yes` and `smtp_sasl_password_maps = mysql:/etc/postfix/mysql_relay_passwords.cf`. – Hawshemi May 23 '23 at 06:27
  • I already doing that but it seems that doesn't work - And if I trace Mysql traffic, idon't see the use of my query so probably mistake on my query - i will investigate – PopFR1 May 23 '23 at 08:03