大网数据广告活动
服务器运维问答

Block email in Postfix based on the "From: " header address

· 52CE 我爱测

I have Postfix configured to block email from a persistent spammer that has found a "bulletproof" spam service provider (known as Amazon SES), but of course the block fails because the MAIL FROM (aka "Return-Path") is a string su…

问题原文

原帖链接 · CraigH · CC BY-SA 4.0

I have Postfix configured to block email from a persistent spammer that has found a "bulletproof" spam service provider (known as Amazon SES), but of course the block fails because the MAIL FROM (aka "Return-Path") is a string such as [email omitted] while the From header passed in the DATA command is [email omitted].

Is there a way to block the address/domain in the From header during the SMTP transaction, rather than filtering it to /dev/null with some after-the-fact process like Sieve, Amavis, Spamassassin, etc.?

This answer suggests it's not possible, but then goes on to emphasise a different point that is not relevant to my question, so it's not clear to me that it is absolutely not possible.

I don't think my postconf output is relevant to this question, as Postfix is running as it should be (I'm running 2.10.1.). I'm looking for a configuration tweak. Thanks.

已采纳解答

原帖链接 · CraigH · CC BY-SA 4.0

Just to show that the suggestion feature when you enter a subject works, when I entered the subject for this question the first result was a link to Route mail in postfix to different relays based on subject. It's not what I was looking for, but it led me to look more closely at header_checks despite what is stated in the answer at the link in my question. A web search led me to How to filter mail with postfix header_checks, which was the answer I was looking for.

In my case this worked in /etc/postfix/header_checks:

/^From:.*partyfixx/ REJECT

I actually put a very rude message after "REJECT", but that's not appropriate to include here.

Here is the log entry for their most recent attempt:

Sep 25 01:41:54 mymailserver postfix/cleanup[19112]: F2A6428C3FD: reject: header From: The Party Fixx Company <[email omitted]> from a9-98.smtp-out.amazonses.com[54.240.9.98]; from=<[email omitted]> to=<[email omitted]> proto=ESMTP helo=<a9-98.smtp-out.amazonses.com>: 5.7.1 Rude message redacted!!!

The regex is case insensitive.

Other answers I found useful:

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2018-09-26)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。