Why do emails to a user in my database with an alias domain hit the server but get bounced (and the inbox is not created)?


This Content is from ServerFault. Question asked by total-N00b

Can anyone tell me what’s wrong? Why do emails to a user in my database with an alias domain hit the server but get bounced (and the inbox is not created)?


I have postfix pgsql set up with a PostgreSQL database so that when I add a user (with a @maindomain.com address) in table mailaccounts, they can receive an email. What I want is to be able to add a user in the database with an alias domain like @aliasdomain.com and have that mapped to @maindomain.com. Or in other words, have a user like johndoe1@aliasdomain.com be able to receive emails just like johndoe1@maindomain.com would.


When I try to send an email from a trusted server like Google to a user in the database (with the alias domain) such as johndoe1@aliasdomain.com, the attempt does hit my server but I get a “user unknown” error.

The main issue is that the virtual alias maps seem to replace @aliasdomain.com with @maindomain.com as intended, but whatever mechanism actually creates the inbox for the new user as would happen if I had sent it to a @maindomain.com user that was in the database.

Postfix logs of error:

Sep 19 02:35:37 mail postfix/lmtp[20721]: 2633A411EC: to=<johndoe1@maindomain.com>, orig_to=<johndoe1@aliasdomain.com>, relay=[]:10024, delay=1.5, delays=0.38/0.01/0.01/1.1, dsn=2.0.0, status=sent (250 2.0.0 from MTA(smtp:[]:10025): 250 2.0.0 Ok: queued as 7210F41237)
Sep 19 02:35:37 mail postfix/qmgr[5088]: 2633A411EC: removed
Sep 19 02:35:37 mail postfix/virtual[20725]: 7210F41237: to=<johndoe1@maindomain.com>, relay=virtual, delay=0.06, delays=0.01/0.02/0/0.03, dsn=5.1.1, status=bounced (unknown user: "johndoe1@maindomain.com")
Sep 19 02:35:37 mail postfix/cleanup[20720]: 8080D41238: message-id=<20220919003537.8080D41238@mail.maindomain.com>
Sep 19 02:35:37 mail postfix/bounce[20727]: 7210F41237: sender non-delivery notification: 8080D41238


Here are some configs:

MX record of alias domain:
Type Name Content
MX aliasdomain.com mail.maindomain.com

in /etc/postfix/main.cf:

local_recipient_maps =
virtual_uid_maps = static:1001
virtual_gid_maps = static:1002
transport_maps = pgsql:/etc/postfix/pgsql/transport.cf
virtual_mailbox_base = /mnt/mailserver-volume1/mail/
virtual_mailbox_maps = pgsql:/etc/postfix/pgsql/mailboxes.cf
#virtual_alias_maps = pgsql:/etc/postfix/pgsql/aliases.cf
virtual_alias_domains = aliasdomain.com
virtual_alias_maps = hash:/etc/postfix/virtual

in /etc/postfix/virtual

@aliasdomain.com     @maindomain.com

I’ve also run the command

postman /etc/postfix/virtual

to get the virtual.db file for the aliases.


This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.

This Question and Answer are collected from serverfault, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?