我的一些用户正在使用 Gmail 向我们的域发送邮件(该邮件服务器托管在带有 postfix 的 CentOS 5 计算机上)。有时(但并非总是如此)当他们这样做时,他们会收到类似以下内容的退回邮件:
---------- Forwarded message ----------
From: Mail Delivery Subsystem <[email protected]>
Date: Mon, Aug 19, 2013 at 9:12 AM
Subject: Delivery Status Notification (Failure)
To: [email protected]
Delivery to the following recipient failed permanently:
[email protected]
Technical details of permanent failure:
Google tried to deliver your message, but it was rejected by the server for the recipient domain domain.com by mail.domain.com. [xxx.xxx.xxx.xxx].
The error that the other server returned was:
502 5.5.2 Error: command not recognized
----- Original message -----
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=;
h=mime-version:sender:in-reply-to:references:date:message-id:subject
:from:to:content-type;
bh=...=;
b=...==
MIME-Version: 1.0
X-Received: by xxx.xxx.xxx.xxx with SMTP id ...;
Mon, 19 Aug 2013 06:12:55 -0700 (PDT)
Sender: [email protected]
Received: by xxx.xxx.xxx.xxx with HTTP; Mon, 19 Aug 2013 06:12:55 -0700 (PDT)
In-Reply-To: <[email protected]>
References: <[email protected]>
<[email protected]>
<....gmail.com>
<....gmail.com>
Date: Mon, 19 Aug 2013 09:12:55 -0400
X-Google-Sender-Auth: ...
Message-ID: <[email protected]>
Subject: ...
From: <[email protected]>
To: <[email protected]>
Content-Type: multipart/alternative; boundary=...
但奇怪的是,邮件仍然发送出去...
检查我的邮件日志后,我看到类似以下内容的行:
Aug 19 9:12:36 domain postfix/smtpd[...]: connect from mail.google.com[xxx.xxx.xxx.xxx]
Aug 19 9:12:37 domain postfix/smtpd[...]: XXXX: mail.google.com[xxx.xxx.xxx.xxx]
Aug 19 9:12:37 domain postfix/smtpd[...]: warning: non-SMTP command from mail.google.com[xxx.xxx.xxx.xxx]: h=mime-version:sender:in-reply-to:references:date:message-id:subject
Aug 19 9:12:37 domain postfix/smtpd[...]: disconnect from mail.google.com[xxx.xxx.xxx.xxx]
看起来好像我的邮件服务器将“h=mime”行解释为命令。
经过一番研究,我关注了以下帖子:
http://serverfault.com/questions/379964/postfix-unknown-command/380248#380248
我添加了
smtpd_command_filter = pcre:/etc/postfix/bogus_commands
参数添加到我的 /etc/postfix/main.cf 文件中,然后在 bogus_commands 文件中增加一些正则表达式,尝试替换以 开头的任何命令
h=mime
到
NOOP
但是,我尝试过的所有正则表达式似乎都不起作用。
我试过:
/^.*h=mime.*$/\s NOOP
preg_replace(^.*h=mime.*$, NOOP, )
/.*h=mime.*/ NOOP
有人能帮我找到我需要的正则表达式的正确语法吗?我绝对不是正则表达式专家。我可能只是做错了一些简单的事情。如果您能提供任何帮助,我将不胜感激。
答案1
在我的特定情况下,事实证明我使用了错误版本的 postfix 来尝试实现 smtpd_command_filter 参数。将 postfix 更新到最新版本后,现在一切正常。