澄清与定位 Postman 是用于发送与测试 HTTP 请求的 API 工具,不能直接创建或管理邮件的收件箱过滤规则。若你的目标是“在 Debian 上实现邮件过滤”,应改为配置邮件服务器(如 Postfix)及其过滤组件(如 header_checks/body_checks、SpamAssassin、Postgrey 等)。下面给出在 Debian 上可落地的邮件过滤实现路径与示例。
方案一 Postfix 内置 header_checks 与 body_checks 正则过滤
header_checks = regexp:/etc/postfix/header_checks
body_checks = regexp:/etc/postfix/body_checks
/Subject:.*A funny game/ DISCARD drop header deny
/免费领取/ DISCARD drop body deny
postmap -q - regexp:/etc/postfix/header_checks < /etc/postfix/header_checks
postmap -q - regexp:/etc/postfix/body_checks < /etc/postfix/body_checks
systemctl reload postfix
方案二 内容过滤与反垃圾 SpamAssassin 集成
sudo apt-get update
sudo apt-get install spamassassin spamc
sudo systemctl enable --now spamassassin
content_filter = spamassassin:127.0.0.1:1000
spamassassin unix - n n - - pipe
flags=R user=spamd argv=/usr/bin/spamc -f -e /usr/sbin/sendmail -oi -f ${sender} ${recipient}
sudo postfix reload
方案三 灰名单 Postgrey 降低垃圾邮件命中率
sudo apt-get install postgrey
sudo sed -i 's/^POSTGREY_OPTS=.*/POSTGREY_OPTS="-inet=127.0.0.1:10023 -delay=60"/' /etc/default/postgrey
sudo systemctl enable --now postgrey
smtpd_recipient_restrictions =
permit_mynetworks,
permit_sasl_authenticated,
reject_unauth_destination,
check_policy_service inet:127.0.0.1:10023
sudo postfix reload
方案四 客户端侧 IMAP 过滤(如 imapfilter)
sudo apt-get install imapfilter
account = IMAP {
server = 'imap.example.com',
username = 'user@example.com',
password = '********',
ssl = 'tls1.2'
}
inbox = account.INBOX
invoice = inbox:contain_subject('发票')
invoice:move_messages(account.INVOICE)
imapfilter -c ~/.imapfilter/config.lua
验证与运维要点
postmap -q 校验正则,变更后用 postfix reload 生效。