Fixing Debian Postfix, Dovecot, and SpamAssassin: External Emails Not Accepted But Outgoing Mails Sent

Abstract: Resolve Debian Postfix rejecting external emails by fixing inet_interfaces and smtpd_recipient_restrictions.

Created: 2026-10-01 by

External emails are rejected while outgoing mail works because the server's configuration likely restricts incoming connections to localhost or misconfigures relay access. This usually stems from incorrect inet_interfaces settings in Postfix or missing entries in smtpd_recipient_restrictions. Correcting these parameters restores full two-way email functionality for your Debian server.

Diagnosing Incoming vs Outgoing Behavior

The symptom of sending successfully but failing to receive is a classic indicator of a binding or restriction issue. When you send an email, Postfix acts as a Mail Transfer Agent (MTA) connecting to remote servers on port 25. However, when receiving, it must act as a Mail Delivery Agent (MDA) listening on its own interface. If the listener is bound only to 127.0.0.1, external clients cannot reach it, yet local processes can still push mail out.

This behavior often occurs after a fresh installation or a major update where default security settings take precedence over usability. It is crucial to verify that the service is not running as an open relay, which would allow anyone to send mail through your server. The goal is to accept mail for your specific domains from any IP address while restricting relaying to authenticated users or trusted networks.

Checking Postfix Network Bindings

The most common culprit is the inet_interfaces parameter in /etc/postfix/main.cf. By default, some configurations set this to loopback-only to prevent accidental exposure. To fix this, you must change the setting to all or specify the public IP address of your server. This allows Postfix to listen on all network interfaces, making it accessible to the internet.

inet_interfaces = all

After modifying this file, restart the Postfix service using systemctl restart postfix. You can verify the change by running netstat -tlnp | grep :25 or ss -tlnp | grep :25 to ensure the process is listening on 0.0.0.0:25 rather than just 127.0.0.1:25.

Configuring Relay Restrictions

Even if the network binding is correct, Postfix may reject incoming mail due to strict relay restrictions. The smtpd_recipient_restrictions directive controls who can send mail to your server. A typical secure configuration includes checks for valid recipient domains and authentication status.

Ensure that your main.cf contains the following lines to properly handle incoming connections:

smtpd_recipient_restrictions = 
    permit_mynetworks, 
    permit_sasl_authenticated, 
    reject_unauth_destination

The reject_unauth_destination option is critical. It tells Postfix to reject mail for domains that are not listed in mydestination or virtual mailbox domains, unless the sender is authenticated or from a trusted network. Without this, Postfix might treat all incoming mail as unauthorized relay attempts.

For more details on how Postfix handles lookup tables and restrictions, see Understanding Postfix Lookup Table in Tech Support. This resource explains how mydestination interacts with other parameters to determine domain ownership.

Verifying Domain Configuration

Your server must explicitly know which domains it is responsible for. Check the mydestination parameter in /etc/postfix/main.cf. This should include your primary hostname and any domain names you wish to receive mail for.

mydestination = $myhostname, localhost.$mydomain, localhost, example.com, www.example.com

If you are hosting multiple domains, ensure they are all listed here or defined in virtual_mailbox_domains if you are using virtual hosting. Failure to list a domain here will cause Postfix to reject mail for that domain with a "User unknown" or "Relay access denied" error.

Dovecot Integration and Authentication

While Postfix handles delivery, Dovecot manages user authentication and mail storage. If authentication is misconfigured, Postfix cannot verify users via SASL, leading to rejection of incoming mail from authenticated users.

Check the /etc/dovecot/conf.d/10-auth.conf file to ensure that login mechanisms are enabled. Typically, auth_mechanisms = plain login is required for standard email clients. Additionally, verify that the /etc/postfix/master.cf file has the submission service configured correctly for authenticated users.

If you are experiencing broader email issues, consider reviewing Troubleshooting Email Issues with Local Postfix Email Server Setup for additional diagnostic steps related to local delivery failures.

Testing the Configuration

After making changes, test your setup using telnet localhost 25 or nc -vz yourserver.com 25 from an external machine. Attempt to send a test email to a local user. If the connection succeeds but the mail is rejected, check the Postfix logs in /var/log/mail.log for specific rejection reasons.

Common log messages include "Client host rejected: accessing server using 127.0.0.1" which indicates a loopback issue, or "Relay access denied" which points to smtpd_recipient_restrictions. Addressing these specific errors will resolve the discrepancy between outgoing and incoming mail capabilities.

Frequently Asked Questions

Why does my server accept outgoing mail but reject incoming?

This happens when Postfix is bound only to the loopback interface (127.0.0.1) instead of all interfaces. External servers cannot connect to a locally bound service, so incoming connections fail while outgoing ones succeed since they originate from the server itself.

How do I check if my server is an open relay?

You can test for open relaying by attempting to send mail to a non-existent address at a different domain using a tool like swaks or telnet. If the server accepts the mail without requiring authentication for a foreign domain, it is an open relay and needs stricter smtpd_recipient_restrictions.

What is the role of smtpd_recipient_restrictions?

This parameter defines the rules Postfix uses to decide whether to accept or reject a recipient during the SMTP transaction. It typically includes checks for trusted networks, authenticated users, and valid destination domains to prevent spam and unauthorized relaying.

Can SpamAssassin cause incoming mail rejection?

SpamAssassin itself does not reject mail at the SMTP level; it scores messages after acceptance. However, if Postfix is configured to use SpamAssassin via a content filter and the filter fails or times out, it can cause delivery delays or rejections. Ensure your content filter is running and responsive.

How do I verify my mydestination settings?

Run postconf mydestination to view the current list of domains. Ensure your primary domain and any aliases are included. If a domain is missing, Postfix will treat incoming mail for that domain as unauthorized relay traffic and reject it.

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