(no title)
ohlookabird | 3 years ago
virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf,
mysql:/etc/postfix/mysql_virtual_alias_maps_wildcard.cf,
hash:/etc/postfix/virtual
The first file is just regular aliases, and is basically a simpler version of the second file (no SQL selections/filters) and could also be merged into a single query with the second file: user = mail
password = <password>
hosts = 127.0.0.1
dbname = maildb_postfix
query = SELECT a1.goto FROM alias a1
LEFT JOIN alias a2 on (a2.address = '%s')
WHERE '%s' LIKE a1.address
AND a1.active = '1' AND a2.address IS NULL
This works, because the percent sign in the alias is picked up by the LIKE keyword. A setup like this allows me to configure many aliases through Postfix Admin's web admin page, including optional wildcard aliases (depending on which users wants that). It has been working very well for me over the past 15+ years. Also, I haven't looked at that SQL query since then and would likely write it in a nicer way today.Note: with the above code SQL injection could be possible through an alias name, but given that in this setup I am the only one managing the mail accounts, I was willing to take this risk. :-) Postfix Admin might do some cleaning/validation, but I haven't checked on it.
hackernewds|3 years ago
ratww|3 years ago
ohlookabird|3 years ago