-1

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[6134]: BD49D36A76: to=<imaliased@mydomain.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 <imaliased@mydomain.com> User doesn't exist: imaliased@mydomain.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

And /etc/postfix/sql-aliases.cf:

user=mailreader
password=topsecret123
dbname=mail
query=SELECT email FROM aliases WHERE alias='%s'

When I run the query SELECT email FROM aliases WHERE alias='imaliased@mydomain.com' 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.

0

Well, I have it working. Apparently the way I had it set up it was using the local transport, and to do the aliases the way I wanted requires virtual transport. So with basically rewriting my main.cf, and including a bunch of virtual_* stuff (using this as a reference) it now works!

  • You haven't shown your config, so impossible to find out for us. – sebix Nov 11 '15 at 20:42
  • @sebix I didn't show my config, because I know that TLS certs aren't relevant when they have been tested working, etc. Also, I think what I have posted here as an answer is sufficient to point future googlers in the right direction -- most of my config is very specific to my setup, and if you want a config file, copy the linked one. – BenjiWiebe Nov 12 '15 at 0:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.