Postfix Sender Client Access Restrictions Not Working for Subdomains

Abstract: Fix Postfix sender access restrictions not applying to subdomains by prefixing domain entries with an at symbol in the access table.

Created: 2026-09-19 by
Postfix sender client access restrictions fail for subdomains because the default lookup mechanism in sender_access performs exact matches only. To enforce rules on parent domains and all their subdomains, you must explicitly prefix domain names with an at symbol (@) in your restriction tables or utilize the check_sender_access feature with proper regex patterns. This ensures that mail from @sub.example.com is correctly evaluated against rules defined for @example.com.

Understanding Postfix Access Table Lookups

When configuring Postfix to restrict email senders based on their address, administrators typically use the smtpd_sender_restrictions parameter in the main.cf configuration file. A common approach involves defining a hash map file, such as /etc/postfix/sender_access, which contains lists of email addresses or domains paired with actions like REJECT or OK. The critical issue arises when an administrator defines a rule for a primary domain, such as example.com REJECT, expecting it to also block emails from subdomains like sales.example.com. By default, Postfix treats entries in these access files as literal strings. When an incoming email originates from [email protected], Postfix looks for an exact match of sub.example.com in the table. It does not automatically infer that this domain is a child of example.com. Consequently, if only example.com is listed, the lookup fails, and Postfix proceeds to the next restriction in the chain. This behavior is consistent across recent versions including Postfix 3.7.11 on Debian 12. Without explicit instructions to treat the entry as a domain pattern, the restriction remains ineffective for any subdomain structure.

The Correct Syntax for Domain Restrictions

To resolve this mismatch, you need to change how you define domains in your access table. Postfix supports a specific syntax where prefixing a domain name with an at symbol (@) tells the lookup engine to treat the entry as a domain suffix rather than an exact string match. This means that defining @example.com REJECT will match [email protected], [email protected], and critically, [email protected]. You should edit your sender access file, usually located at /etc/postfix/sender_access. Remove any existing entries that look like bare domain names without the leading at sign. Replace them with the correct format. For example:
# /etc/postfix/sender_access
@example.com    REJECT Sender domain blocked
@spam-domain.net    REJECT Known spam source
After making changes to the text-based access file, you must generate the binary database file that Postfix actually reads. Run the following command to rebuild the hash map:
sudo postmap /etc/postfix/sender_access
This creates a new file named /etc/postfix/sender_access.db. Ensure that the permissions on this file are readable by the Postfix process, typically owned by root but accessible by the postfix user group. Finally, reload the Postfix configuration to apply the changes:
sudo systemctl reload postfix

Alternative Approach Using Regular Expressions

If you require more complex matching logic, such as blocking multiple subdomains with varying patterns, you can use regular expression maps instead of plain hash maps. This method involves creating a separate file, often named /etc/postfix/sender_regexp, and configuring Postfix to use the regexp lookup type. In your main.cf, ensure your restriction calls the regexp map:
smtpd_sender_restrictions = check_sender_access regexp:/etc/postfix/sender_regexp, ...
Inside the regexp file, you can use Perl-compatible regular expressions to match subdomains dynamically. For instance, to block any subdomain of example.com, you might use a pattern like:
/\@.*\.example\.com$/    REJECT Subdomain blocked
However, note that regular expression lookups can be slower than hash lookups and may introduce performance overhead on high-volume servers. For most standard administrative tasks, the @ prefix method in hash maps is preferred due to its simplicity and speed. If you decide to use regexp, remember to run postmap on the regexp file as well, although some configurations allow direct reading depending on the setup.

Verifying the Configuration

Once the configuration is updated, testing is essential to confirm that subdomains are now being restricted. You can simulate an incoming email using the sendmail command line utility or through an SMTP client. Attempt to send an email from a subdomain address that should be blocked. Check the Mail log, typically found at /var/log/mail.log or /var/log/syslog, for entries indicating that the sender was rejected. Look for log messages containing "reject" and the reason provided in your access table. If the rejection occurs, the configuration is working correctly. If not, verify that the sender_access file is referenced in the correct order within smtpd_sender_restrictions. Postfix evaluates restrictions sequentially; if an earlier rule accepts the connection, subsequent sender checks may be skipped. Ensure no preceding rule inadvertently allows the traffic before reaching your sender restrictions. For related issues regarding email delivery on different network setups, you might find Handling Email Delivery with Dynamic IP Addresses on Ubuntu Server using Postfix useful, as network constraints can sometimes mask configuration errors. Additionally, understanding how envelope addresses interact with headers is crucial for comprehensive email management, as detailed in Change Postfix Sender Envelope MAIL FROM Address To Match Return Path Header Email For Multiple Domains.

Frequently Asked Questions

Why did my existing rules stop working after upgrading?

Upgrading Postfix does not typically change the fundamental lookup behavior of access tables, but configuration defaults or migration scripts might reset certain parameters. Always verify that your main.cf still points to the correct access files and that the syntax remains valid for the new version.

Can I mix exact address and domain restrictions in one file?

Yes, you can mix both types in a single sender_access file. Exact matches like [email protected] REJECT will work alongside domain suffixes like @example.com REJECT. Postfix processes the file line by line, so place more specific rules above general domain rules to ensure they take precedence.

What is the difference between sender_access and recipient_access?

sender_access evaluates the MAIL FROM command (the envelope sender), while recipient_access evaluates the RCPT TO command (the envelope recipient). They serve different purposes; sender restrictions often control who can relay or send bulk mail, whereas recipient restrictions manage mailbox availability and routing.

How do I debug why a rule is not triggering?

Enable verbose logging by setting debug_peer_list in main.cf for the specific server IP or domain. Restart Postfix and attempt a connection. Check the logs for detailed lookup results showing whether Postfix found a match in the access table or proceeded to the next rule due to a miss.

Is there a performance impact when using too many access rules?

Hash maps (hash:) are highly optimized and generally have negligible performance impact even with thousands of entries. However, regular expression maps (regexp:) can slow down processing significantly if the patterns are complex or numerous. Stick to hash maps for simple list-based restrictions whenever possible.

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