Before the queue
PDC runs as a Postfix policy service during RCPT TO.
Broken destinations are rejected before message acceptance.
PDC checks recipient domains during RCPT TO and gives users an immediate,
readable hint when a destination looks wrong — including a likely correction when
the intended domain can be identified safely.
235 2.7.0 Authentication successful
MAIL FROM:<user@example.org>
250 2.1.0 Ok
RCPT TO:<gn@gimail.com>
550 5.1.2 Recipient address rejected:
The recipient domain "gimail.com"
does not have a usable mail exchanger.
Did you mean "gmail.com"?
The goal is deliberately narrow: catch obvious recipient-domain mistakes at the MSA while the sender can still correct them immediately.
PDC runs as a Postfix policy service during RCPT TO.
Broken destinations are rejected before message acceptance.
Instead of a later generic MAILER-DAEMON bounce, the sender gets an immediate, understandable SMTP error.
A working mail domain is never rejected just because it resembles another domain. Suggestions are considered only after the destination is already known to be unusable.
MX 0 . explicitly says that the domain does not accept mail.
localhost, loopback-only targets, or MX hosts without usable A/AAAA.
DUNNO instead of blocking legitimate mail.
Canonical domains live in an external domains.txt. PDC reloads it when the file changes,
so updates do not require code changes or a service restart.
Matching is intentionally conservative: one substituted, inserted or deleted character,
or one adjacent transposition. That also catches simple TLD mistakes such as
kabelmail.co → kabelmail.com.
gmail.com
outlook.com
gmx.de
web.de
kabelmail.com
t-online.de
proton.me
apt install python3-dnspython
mkdir -p /opt/pdc
install -m 0755 pdc.py /opt/pdc/
install -m 0644 domains.txt typo-map.txt /opt/pdc/
pdc unix - n n - 0 spawn
user=nobody argv=/opt/pdc/pdc.py
smtpd_recipient_restrictions =
reject_non_fqdn_recipient,
check_policy_service unix:private/pdc,
permit_mynetworks,
permit_sasl_authenticated,
...
permit_mynetworks and
permit_sasl_authenticated, otherwise those PERMIT results
short-circuit the restriction list.
postfix check
postfix reload
On the MSA path, PDC is intended to replace
reject_unknown_recipient_domain, not sit next to it.
Postfix does not expose that restriction's DNS result to policy services,
so PDC cannot directly reuse it.
PDC asks for MX first. A/AAAA are queried only if no MX RRset exists. A valid MX or Null MX therefore normally needs only one resolver lookup.
reject_non_fqdn_recipient,
check_policy_service unix:private/pdc,
permit_mynetworks,
permit_sasl_authenticated
reject_non_fqdn_recipient,
reject_unknown_recipient_domain,
check_policy_service unix:private/pdc,
...
smtp(8) delivery attempts are usually cache hits instead of new external DNS traffic.
Successful recipients are intentionally quiet. PDC logs rejects, defers, configuration errors and internal errors.
pdc: action="reject" sasl="user@example.org" recipient="x@gimail.com" domain="gimail.com" reason="unusable_mx" suggestion="gmail.com"
pdc: action="defer" sasl="user@example.org" recipient="x@broken.example" domain="broken.example" reason="dns_tempfail"
Run the daemon interactively and terminate the request with an empty line.
/opt/pdc/pdc.py
protocol_state=RCPT
sasl_username=testuser
recipient=someone@gimail.com
action=550 5.1.2 ... Did you mean "gmail.com"?
Python · Postfix policy delegation · MIT License