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

How do I configure postfix to reject all email that doesn't have a specific 'from' field?

· 52CE 我爱测

I have an SMTP relay that relays to our email forwarding server but currently it's accepting mail from all sorts of nasty spammers and our email forwarding host have (rightly) suspended the forwarding until we can lock things dow…

问题原文

原帖链接 · Jon Cage · CC BY-SA 4.0

I have an SMTP relay that relays to our email forwarding server but currently it's accepting mail from all sorts of nasty spammers and our email forwarding host have (rightly) suspended the forwarding until we can lock things down a bit more. I'd therefore like to lock down this relay so that only emails with a specific 'from' value are accepted as a good start.

As per the Q-A in Rejecting unlisted senders in Postfix, I've tried setting this in main.cf:

smtpd_sender_restrictions =
    check_sender_access hash:/etc/postfix/acl_unknown_permited
    reject_unlisted_sender

..and making a new file /etc/postfix/acl_unknown_permited with the following content:

[email omitted] permit

...with the appropriate server name.

This doesn't appear to be rejecting email though as setting the sender address to something outside of [email omitted] like [email omitted] is not rejected.

Is there another setting that could be overriding what I've set here?

The only thing I can think might be going awry at this point is the target of our relay is currently deferring email send attempts. Could that be masking the issue (I was expecting the rejection to happen before we hit the following error and I'm wary to open up the next stage until we've fully tied down the relay)?

Apr 25 22:13:37 smtp-relay postfix/smtp[447151]: BE0FB4247C: to=<[email omitted]>, relay=email.forwarder.com [X.X.X.X]:587, delay=0.29, delays=0.09/0.02/0.17/0, dsn=4.0.0, status=deferred (SASL authentication failed; server email.forwarder.com [X.X.X.X] said: 535 Too many failed login requests from Y.Y.Y.Y. Try again later. #MS-ST-D)

已采纳解答

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

Sounds like the beginning of a larger reevaluation, so lets start with two items:

  1. Postfix SMTPd restrictions are enforced in the SMTP daemon: once, while choosing whether to accept submitted mail and queue it, or whether to reject it. After placing additional restrictions on newly accepted mail, you still have to manually sort out unwanted mail already accepted to your queue. Run postqueue -p to produce a listing of what the queue currently looks like. If you cannot easily determine that each and every queue item is unauthorized, you will find ways to separate the wheat from the chaff by looking up postsuper instructions.

  2. Just placing restrictions on acceptable envelope senders may have little or no impact on how much spam you relay - spammers could likely still send mail using any header from address and any content. You likely want to enforce substantial additional restrictions, such as requiring sender to authenticate, or requiring mail to originate from specific networks (IPv4/IPv6) under your control (often done via setting mynetworks).

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

资料来源与适用范围

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

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

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