Postfix Email Aliases Not Working: Fixing “User unknown in local recipient table” Error with virtual_maps


2 views

When your Postfix server rejects emails with "User unknown in local recipient table" despite having proper virtusertable entries, there are several critical configuration points to verify:

# First check if your virtusertable is properly compiled
sudo postmap /etc/postfix/virtusertable
sudo systemctl reload postfix

The key issue in your configuration is the deprecated virtual_maps parameter. Modern Postfix versions use:

# In /etc/postfix/main.cf
virtual_alias_domains = mydomain.com
virtual_alias_maps = hash:/etc/postfix/virtusertable

For Cyrus integration, ensure your mailbox transport properly handles the mapped addresses:

mailbox_transport = lmtp:unix:/var/run/cyrus/socket/lmtp
local_recipient_maps = $virtual_alias_maps

Here's a verified setup that works with Cyrus and virtual aliases:

# /etc/postfix/main.cf
virtual_alias_domains = mydomain.com
virtual_alias_maps = hash:/etc/postfix/virtusertable
local_recipient_maps = $virtual_alias_maps
mailbox_transport = lmtp:unix:/var/run/cyrus/socket/lmtp
local_transport = virtual

Verify your mapping works with these diagnostic commands:

# Test address mapping
postmap -q "myuser@mydomain.com" hash:/etc/postfix/virtusertable

# Check Postfix lookup tables
postconf -n | grep alias

When using fetchmail with virtual mappings, ensure the local delivery matches:

# /etc/fetchmailrc adjustment
poll "mail.pop3server.com"
  protocol pop3
  user "myuser@mydomain.com" password "12345"
  to "myuser"  # Must match virtusertable mapping

When working with Postfix and Cyrus IMAP integration, email aliasing through virtusertable should theoretically be straightforward. However, the error message Recipient address rejected: User unknown in local recipient table indicates Postfix isn't properly recognizing your virtual alias mapping.

Your setup shows several correct elements:

virtual_alias_domains = mydomain.com
virtual_maps = hash:/etc/postfix/virtusertable

But let's examine the critical missing pieces:

For virtual alias domains to work properly with Cyrus, you need these additional configurations:

# In main.cf
virtual_alias_maps = hash:/etc/postfix/virtusertable
local_recipient_maps = $virtual_alias_maps $alias_maps

Here's the corrected setup that works with Cyrus:

# /etc/postfix/main.cf additions
virtual_alias_domains = mydomain.com
virtual_alias_maps = hash:/etc/postfix/virtusertable
local_recipient_maps = $virtual_alias_maps $alias_maps
mailbox_transport = lmtp:unix:/var/run/cyrus/socket/lmtp

Your virtusertable should look like this:

# /etc/postfix/virtusertable
myuser@mydomain.com    myuser
@mydomain.com          catchall

Then compile it with:

postmap /etc/postfix/virtusertable
systemctl reload postfix

Verify with these commands:

postconf -n | grep virtual
postmap -q myuser@mydomain.com hash:/etc/postfix/virtusertable

Your fetchmailrc is correctly configured, but ensure Postfix can process the retrieved messages:

# Test with manual delivery
sendmail -bv myuser@mydomain.com

Check these logs after attempting delivery:

tail -f /var/log/mail.log
journalctl -u postfix -f

You should see successful LMTP delivery to Cyrus instead of the "user unknown" error.