When configuring a Postfix mail server, one common issue administrators encounter is the Recipient address rejected: User unknown in local recipient table
error when sending emails to addresses within the same domain. This occurs specifically when attempting to send to addresses under your server's primary domain (e.g., test@example.com when your server is mail.example.com).
The error stems from Postfix's configuration in main.cf
where the mydestination
parameter isn't properly handling local domain delivery. In the provided configuration:
mydestination = $mydomain, localhost.$mydomain, localhost
The issue arises because Postfix considers itself the final destination for these domains but lacks proper user mapping.
Here are three approaches to resolve this:
Solution 1: Virtual Mailbox Domains
For modern Postfix setups using virtual mailboxes:
virtual_mailbox_domains = example.com
virtual_mailbox_maps = hash:/etc/postfix/virtual_mailbox
virtual_minimum_uid = 100
virtual_uid_maps = static:5000
virtual_gid_maps = static:5000
Create the virtual mailbox map file:
# /etc/postfix/virtual_mailbox
test@example.com example.com/test/
Solution 2: Local Mailbox Configuration
For traditional local delivery:
mydestination = $myhostname, localhost.$mydomain, localhost
local_recipient_maps = $alias_maps unix:passwd.byname
Then ensure the user exists in the system:
sudo adduser test
Solution 3: Hybrid Approach
Combine both methods for flexibility:
mydestination = $myhostname, localhost.$mydomain, localhost
virtual_alias_maps = hash:/etc/postfix/virtual
Virtual aliases file example:
# /etc/postfix/virtual
test@example.com realuser@otherdomain.com
After making changes, always:
sudo postfix check
sudo postfix reload
Test email delivery with:
echo "Test email" | mail -s "Test" test@example.com
Check logs with:
tail -f /var/log/mail.log
If issues persist, examine these Postfix parameters:
postconf -n
Key parameters to verify:
mydomain
should match your domainmyorigin
should be properly setinet_interfaces
should include all necessary interfacesmynetworks
should properly define trusted networks
When configuring a Postfix mail server, one common issue arises when sending emails to addresses within the same domain as the server (e.g., mail.example.com trying to send to test@example.com). The server logs show:
Recipient address rejected: User unknown in local recipient table
This occurs because Postfix is configured to treat the domain as a local delivery domain but lacks proper user mapping.
The critical line in your main.cf is:
mydestination = $mydomain, localhost.$mydomain, localhost
This tells Postfix to handle mail for these domains locally, but without corresponding user accounts or virtual mailbox mappings, delivery fails.
Option 1: Virtual Mailbox Mapping
For production systems with multiple users, implement virtual mailbox mapping:
# Add to main.cf
virtual_mailbox_domains = example.com
virtual_mailbox_maps = hash:/etc/postfix/virtual_mailbox
virtual_minimum_uid = 1000
virtual_uid_maps = static:5000
virtual_gid_maps = static:5000
Then create /etc/postfix/virtual_mailbox:
test@example.com example.com/test/
Option 2: Local Unix Accounts
For simple setups with few users:
# Create system account
sudo adduser testuser
# Set password
sudo passwd testuser
# Add to Postfix local_recipient_maps
local_recipient_maps = proxy:unix:passwd.byname $alias_maps
After changes, always test:
# Reload Postfix
sudo systemctl reload postfix
# Check configuration
postconf -n
# Test delivery
echo "Test email" | mail -s "Test" test@example.com
Enable verbose logging temporarily:
# In main.cf
debug_peer_list = example.com
debug_peer_level = 2
Then monitor logs:
tail -f /var/log/mail.log