Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Some of my users are using Gmail to send mail to our domain (The mail server for which is hosted on a CentOS 5 machine with postfix). Sometimes, but not all the time, when they do, they get a bounceback similar to:

---------- Forwarded message ----------
From: Mail Delivery Subsystem <>
Date: Mon, Aug 19, 2013 at 9:12 AM
Subject: Delivery Status Notification (Failure)

Delivery to the following recipient failed permanently:

Technical details of permanent failure:
Google tried to deliver your message, but it was rejected by the server for the       recipient domain by [].

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;; s=;
MIME-Version: 1.0
X-Received: by with SMTP id ...;
 Mon, 19 Aug 2013 06:12:55 -0700 (PDT)
Received: by with HTTP; Mon, 19 Aug 2013 06:12:55 -0700 (PDT)
In-Reply-To: <>
References: <>
Date: Mon, 19 Aug 2013 09:12:55 -0400
X-Google-Sender-Auth: ...
Message-ID: <>
Subject: ...
From: <>
To: <>
Content-Type: multipart/alternative; boundary=...  

But the weird thing is, the mail still goes through...
Upon inspection of my maillogs, I see lines similar to:

Aug 19 9:12:36 domain postfix/smtpd[...]: connect from[]
Aug 19 9:12:37 domain postfix/smtpd[...]: XXXX:[]
Aug 19 9:12:37 domain postfix/smtpd[...]: warning: non-SMTP command from[]:         h=mime-version:sender:in-reply-to:references:date:message-id:subject
Aug 19 9:12:37 domain postfix/smtpd[...]: disconnect from[]  

It appears as though my mail server is interpreting the "h=mime" line as a command.
After some research, I followed this thread:  

and I added the

smtpd_command_filter = pcre:/etc/postfix/bogus_commands  

parameter to my /etc/postfix/ file, then added some regex to the bogus_commands file to try and replace any command beginning with




But, none of the regex I've tried seems to be working.
I have tried:

/^.*h=mime.*$/\s NOOP  

preg_replace(^.*h=mime.*$, NOOP, )  

/.*h=mime.*/ NOOP  

Can anyone help me find the proper syntax for the regex that I need for this to work? I'm not a regex expert by any means. I'm probably just doing something simple wrong. Any help you can provide is most appreciated.

share|improve this question
How about this? preg_replace('/^.*h=mime.*$/', 'NOOP', ) – Danila Ladner Aug 19 '13 at 18:19
Didn't work unfortunately. After I added it to the bogus_commands file, I did a condrestart on postfix then tried telnet-ing into the mail server on port 25 and typing "h=mime" it replied "502 5.5.2 Error: Unknown Command". I believe that if the filter was working then it would respond "520 2.0.0 OK". But, I've never done this before. – Chris Powell Aug 19 '13 at 18:29
can you try with this? postmap -q "string" pcre:/etc/postfix/filename – Danila Ladner Aug 19 '13 at 18:52
Same result. Maybe I should try reloading postfix instead of just a condrestart? – Chris Powell Aug 19 '13 at 19:04
I think I may have found out something important. On the man page for smtpd_command_filter, it says right at the bottom "available in postix 2.7". I, as it turns out, only have postfix 2.3.3. I'll update postfix and try again. – Chris Powell Aug 19 '13 at 19:17
up vote 1 down vote accepted

In my particular case, it turns out I was using an incorrect version of postfix to try and implement the smtpd_command_filter parameter. After updating postfix to the latest version, everything is working fine now.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.