Postfix - Recipient address rejected: User unknown in local recipient table
Stefan Bogdanescu
Founder & Senior Architect
Postfix Nightmare Solved: Decoding "Recipient address rejected" in Your Mail Server Setup
Building your own mail server is an incredibly rewarding project, offering deep insight into network protocols and system administration. However, diving into the complexities of Postfix configuration often leads to frustrating roadblocks. As a senior developer, I’ve seen countless issues arise when setting up mail delivery systems, especially when dealing with external relays like Gmail or custom domain setups without full DNS integration.
Today, we are tackling a very common and specific error: Recipient address rejected: User unknown in local recipient table. This post will dissect why this happens in Postfix, analyze your provided configuration snippets, and provide the robust solutions needed to get your mail delivery working smoothly.
Understanding the Error: Why Does Postfix Reject Mail?
The error message you are seeing—Recipient address rejected: User unknown in local recipient table—is Postfix’s way of saying, "I received an email addressed to john@yourdomain.com, but I do not have a corresponding user account defined locally to deliver this message to."
When Postfix processes incoming mail for local delivery or when it attempts to map recipients using configuration directives like local_recipient_maps and alias_maps, it consults its internal tables (like /etc/aliases) to determine the correct destination. If the entry for the recipient is missing, Postfix defaults to rejection, which stops the delivery process immediately.
In your specific case, where you are relaying mail from an external source (Gmail) and setting up a system that relies on IP-only addressing without full DNS records, this mapping failure becomes critical.
Analyzing Your Postfix Configuration
Let's look closely at the configuration you provided to pinpoint the issue:
/etc/aliases
john: john
And your Postfix settings:
relay_recipient_maps = alias_maps = hash:/etc/aliases
local_recipient_maps = unix:passwd.byname $alias_maps
smtpd_recipient_restrictions =
permit_sasl_authenticated
permit_mynetworks
reject_unauth_destination
The configuration correctly points Postfix to use the /etc/aliases file for mapping recipients. The problem lies in the assumption that john@<myip> exists locally based on the external request, or how Postfix handles the interaction between system-level mappings (passwd.byname) and alias mappings (alias_maps).
The core issue is likely that the mechanism used to map the recipient address (the local_recipient_maps chain) fails because it cannot find a valid entry for the target user, leading to the final rejection by reject_unauth_destination.
The Solution: Ensuring Robust Recipient Mapping
Since you are operating on an IP-only setup and relying on local files, we need to ensure that the system-level mappings are correctly integrated. While your /etc/aliases looks fine for a basic local user, we must ensure Postfix is configured to handle external delivery paths gracefully, especially when dealing with relay errors.
Step 1: Verify System User Existence
First, confirm that the user john actually exists on your CentOS system and has a valid entry in /etc/passwd. If it does, the issue shifts from user existence to PostFix mapping logic.
Step 2: Adjusting Recipient Maps for Security and Reliability
For modern mail servers, especially those acting as relays, relying solely on simple alias maps can be brittle. A more robust approach is often necessary. While Postfix provides many ways to handle this, ensuring that smtpd_recipient_restrictions correctly filters based on authenticated users is key.
If you are strictly using IP addresses without a fully configured domain structure (as noted by your lack of DNS records), you might need to adjust how Postfix handles destinations:
# Example refinement for stricter control and clarity
smtpd_recipient_restrictions =
permit_sasl_authenticated
permit_mynetworks
reject_unauth_destination
The current setup is technically correct for rejecting unauthorized destinations, but the failure occurs before that final check because the initial recipient lookup fails.
Best Practice: Embracing Structured Configuration
When developing complex systems like mail servers, think about modularity and strict configuration structure. This philosophy mirrors how well-structured applications are built, much like principles found in modern frameworks like Laravel, where clear separation of concerns leads to maintainable codebases. Applying this disciplined approach to system administration helps prevent these obscure errors down the line.
Conclusion
The Recipient address rejected error is typically a symptom of a mismatch between the external request and the internal recipient database Postfix is authorized to use. By thoroughly checking your /etc/aliases, ensuring all necessary user entries exist in /etc/passwd, and understanding how local_recipient_maps chains interact with your security restrictions, you can resolve this issue. Debugging mail systems requires methodical configuration review, moving step-by-step from the entry point (the SMTP connection) to the final delivery decision. Happy mail server building!