我正在使用 Postfix,并尝试在“Received:”标头中将字符串“14.03.0513.000”替换为“15.20.7091.31”,类似于以下:
Received: from srv1.somedomain.com ([11.12.13.14]) by srv2 ([12.13.14.15]) with mapi id 14.03.0513.000; Fri, 15 Dec 2023 14:28:13 -0500
但是,我似乎无法正确使用语法。我尝试在 /etc/postfix/header_checks 中进行类似操作,但一旦启用它,Postfix 就不会接受入站消息(出现 451 4.3.0 错误:队列文件写入错误)
/^Received:(.*)14\.03\.0513\.000(.*)/ REPLACE Received:${1}15.20.7091.31${2}
我可以跑
postmap -q "Received: from srv1.somedomain.com ([11.12.13.14]) by srv2 ([12.13.14.15]) with mapi id 14.03.0513.000; Fri, 15 Dec 2023 14:28:13 -0500" regexp:/etc/postfix/header_checks
我收到了回复
REPLACE Received: from srv1.somedomain.com ([11.12.13.14]) by srv2 ([12.13.14.15]) with mapi id 15.20.7091.31; Fri, 15 Dec 2023 14:28:13 -0500
这似乎是正确的,但 postfix 仍然拒绝该消息。知道我遗漏了什么吗?
答案1
以下是修改后的版本
/^Received: from (.*) by (.*) with mapi id 14\.03\.0513\.000;(.*)/ REPLACE Received: from ${1} by ${2} with mapi id 15.20.7091.31;${3}
此修改会捕获“已接收:”标头的特定部分,以确保更准确的替换。进行此调整后,重新加载或重新启动 Postfix,看看问题是否仍然存在。