Fixing Debian Postfix, Dovecot, and SpamAssassin: External Emails Not Accepted, Outside Addresses Not Sent

Abstract: Fixes external email rejection and outgoing mail failure in Debian Postfix by correcting the smtpd_relay_restrictions parameter order.

Created: 2026-08-16 by
The issue stems from the incorrect order of parameters in your Postfix main configuration file, specifically within the smtpd_relay_restrictions directive. When permit_mynetworks is placed after reject_unauth_destination, Postfix rejects valid local sender connections before checking if they are authorized, effectively blocking external emails and outgoing mail despite correct network settings.

Understanding the Relay Restriction Logic

Postfix uses a specific logic flow to determine whether an email should be accepted or relayed. The smtpd_relay_restrictions parameter defines this sequence. It is critical to understand that these restrictions are evaluated in the exact order they appear in the configuration file. If a rule matches, processing stops for that check. The most common mistake occurs when administrators place the reject_unauth_destination restriction before permit_mynetworks. This causes Postfix to reject any email not destined for a local domain immediately, even if the client connecting is from a trusted local IP address. This results in the symptom where you cannot send emails externally, nor can you receive them from outside sources if the connection originates from a local interface. To fix this, you must ensure that trusted networks are permitted first. This allows authenticated users or local services to bypass strict destination checks. Only after confirming the sender is authorized should Postfix verify if the recipient is valid for relaying.

Correcting the Configuration Order

You need to edit the main Postfix configuration file. On Debian systems, this file is typically located at /etc/postfix/main.cf. Open this file using your preferred text editor with root privileges. For example, you might use:
sudo nano /etc/postfix/main.cf
Locate the line defining smtpd_relay_restrictions. It may look something like this in its broken state:
smtpd_relay_restrictions = reject_unauth_destination, permit_mynetworks, permit_sasl_authenticated
This order is incorrect because reject_unauth_destination will trigger first for non-local recipients, causing the rejection before permit_mynetworks has a chance to allow the connection. You must reorder these parameters so that permit_mynetworks comes first. The corrected line should read:
smtpd_relay_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
This ensures that any connection from an IP listed in mynetworks is permitted to relay, regardless of the destination. Next, it checks for SASL authentication. Finally, it rejects any remaining requests that do not meet these criteria. If you also have smtpd_recipient_restrictions defined separately, ensure it follows a similar logical pattern, though often smtpd_relay_restrictions handles the primary relay logic in modern Postfix versions. Always keep reject_unauth_destination as the final catch-all to prevent open relay vulnerabilities. After saving the changes, restart the Postfix service to apply the new configuration. Use the following command:
sudo systemctl restart postfix
Verify the change by sending a test email to an external address. If the issue persists, check the mail log at /var/log/mail.log for any immediate error messages related to relay access. For more detailed troubleshooting on related Postfix delivery issues, you might find Troubleshooting Postfix: Local Delivery despite External Agent Configuration helpful if you suspect local delivery agents are interfering. Additionally, understanding how to manage sender addresses can prevent header mismatches, as discussed in Change Postfix Sender Envelope MAIL FROM Address To Match Return Path Header Email For Multiple Domains.

Verifying MyNetworks Settings

Ensure that your mynetworks variable includes the IP addresses of your server itself and any trusted subnets. Check the /etc/postfix/main.cf file for the mynetworks directive. It should include 127.0.0.0/8 and possibly [::1]/128 for IPv6 localhost. If you are hosting multiple domains or services on the same machine, ensure their IPs are included. An incorrect mynetworks setting can cause the fix above to fail. If permit_mynetworks is first but your IP is not in the list, the next rule will still reject you. You can test your effective mynetworks by running:
postconf mynetworks
Compare the output with your actual server IP addresses. Adjust as necessary and restart Postfix again.

Checking SpamAssassin Integration

Since your setup includes SpamAssassin, ensure it is correctly integrated via content_filter in Postfix. Misconfiguration here can sometimes mimic relay issues by silently dropping or quarantining messages. However, the primary symptom of "external emails not accepted" combined with "outside addresses not sent" strongly points to the relay restriction order rather than content filtering. If you suspect SpamAssassin is involved, check the logs for entries containing "spam" or "SA" during the transmission attempt. If no such entries appear, the message was likely rejected at the SMTP handshake level due to the relay restrictions, confirming the configuration order was the root cause.

Final Verification Steps

After applying the fix, perform comprehensive testing. Send an email from an external account to your server, then send one from your server to an external account. Both should succeed without errors. Monitor the logs during these tests to confirm that the permit_mynetworks rule is being hit successfully. If you continue to face challenges with email acceptance, consider reviewing other common pitfalls. For instance, some administrators encounter issues where emails are auto-deleted due to quota or storage misconfigurations, which is a different problem entirely but worth noting if your symptoms evolve. See Automatically Deleted Postfix Emails for guidance on storage-related deletions.

Frequently Asked Questions

Why does order matter in smtpd_relay_restrictions?

Postfix evaluates restrictions sequentially and stops at the first match. If reject_unauth_destination appears first, it blocks all non-local destinations immediately, ignoring subsequent permit rules. Placing permits first ensures authorized clients are allowed through before strict destination checks occur.

What happens if I leave reject_unauth_destination out entirely?

Removing reject_unauth_destination turns your server into an open relay, allowing anyone to send emails through your server. This is a severe security risk that will lead to your IP being blacklisted by major providers. Always keep this restriction as the final fallback.

How do I check if my network is in mynetworks?

Run postconf mynetworks in the terminal. The output will list the IP ranges Postfix considers local. Ensure your server's public IP and any internal subnets used by mail clients are included in this list.

Can Dovecot affect these relay restrictions?

Dovecot handles IMAP/POP3 access and local delivery but does not directly control Postfix's SMTP relay logic. However, if Dovecot is configured to submit mail via Postfix (using port 587), it relies on the same permit_sasl_authenticated rules. Ensure SASL authentication is working correctly between Dovecot and Postfix.

What log file shows relay rejection errors?

Check /var/log/mail.log or /var/log/mail.err on Debian systems. Look for lines containing "NOQUEUE: reject:" or "relay=none". These entries will specify the reason for rejection, such as "Client host rejected: Access denied," which indicates a restriction mismatch.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More