Score:0

Postfix - Relay - authentificatin in Mysql

se flag

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

When 1 special user ([email protected]) 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 !

Score:0
kz flag

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.

PopFR1 avatar
se flag
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 ?!
Hawshemi avatar
kz flag
@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`.
PopFR1 avatar
se flag
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
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.