I am using Postfix 3.0.2, Dovecot 2.2.18, and MariaDB 10.0.21. Postfix/Dovecot are receiving mail for *@mydomain.com and *@anotherdomain.com (i.e. the MX for both domains are set to this server.) I'm keeping a list of aliases and recipients in some tables in MariaDB.
So far, sending/receiving mail is working, but when I tried to add an alias to my aliases table, Postfix behaved as though the aliases table was emtpy. The Postfix error for when I sent an email to an alias is as follows:
Nov 10 19:02:19 mail.mydomain.com postfix/lmtp: BD49D36A76: to=<email@example.com>, relay=mail.mydomain.com[private/dovecot-lmtp], delay=0.1, delays=0.06/0.01/0.02/0.01, dsn=5.1.1, status=bounced (host mail.mydomain.com[private/dovecot-lmtp] said: 550 5.1.1 <firstname.lastname@example.org> User doesn't exist: email@example.com (in reply to RCPT TO command))
However, if I define an alias in /etc/aliases, the email is forwarded correctly. Here are the relevant lines from main.cf:
alias_maps = hash:/etc/aliases mysql:/etc/postfix/sql-aliases.cf local_recipient_maps = mysql:/etc/postfix/sql-boxes.cf $alias_maps
user=mailreader password=topsecret123 dbname=mail query=SELECT email FROM aliases WHERE alias='%s'
When I run the query
SELECT email FROM aliases WHERE firstname.lastname@example.org' as
mailreader, I do indeed get the destination address as the one and only result, AND it does indeed work to send an email directly to that address!
Does anyone have any suggestions of things to try? I've tried Googling but I can't seem to find any relevant information for using an aliases table in a SQL DB, except that it is supposed to work.