Foreign mail server returns "502 Command not implemented."
I am using Postfix to communicate with foreign server and send a mail. Every time when I try send mail using Postfix, I get this error:
(host mx2.seznam.cz[77.75.76.32] said: 451 Local Error (in reply to end of DATA command))
After a while of debugging, I got SMTP transcription:
220 2.0.0 Seznam SMTP server waiting for your HELO/EHLO
EHLO alpha.tbedrich.cz
250-Email.Seznam.cz - Email zdarma na cely zivot ESMTP
250-8BITMIME
250-SIZE 18000000
250-ENHANCEDSTATUSCODES
250 X-SZNEXTENSIONS
MAIL FROM:<[email protected]> SIZE=1007
250 2.1.0 Ok <[email protected]>
RCPT TO:<[email protected]>
250 2.1.5 Ok <[email protected]>
DATA
354 Start mail input; end with <CRLF>.<CRLF>
Received: from mail-lb0-f176.google.com (mail-lb0-f176.google.com [209.85.217.176])
by alpha.tbedrich.cz (Postfix) with ESMTPSA id 8520F401DB
for <[email protected]>; Thu, 27 Aug 2015 19:09:37 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tbedrich.cz; s=mail;
t=1440695377; bh=CG6CavtqSpj8fj6WkmsWGRsGNN0Qa3sWp3MV/1BiTCY=;
h=From:Date:Subject:To:From;
b=GtnSxBgTLQsBIjn0DTUAm7zgfiIUOJjunmWHeCLSEit+QqyaGy63QzLd4yvzJYNNW
6Fpc2LySSMB3QfxvhNOaxZZaP1aBUVaqH8nGulPgKeC5B67HgKGIpIP8o8F8oEDZyc
G7TPnXC6zA62Nr5FzSlmMYpWwQh4HR2RYEJDvFrU=
Received: by lbbtg9 with SMTP id tg9so15579426lbb.1
for <[email protected]>; Thu, 27 Aug 2015 10:09:36 -0700 (PDT)a
X-Received: by 10.152.21.231 with SMTP id y7mr2710607lae.63.1440695376852;
Thu, 27 Aug 2015 10:09:36 -0700 (PDT)
MIME-Version: 1.0
From: =?UTF-8?B?VG9tw6HFoSBCZWTFmWljaA==?= <[email protected]>
Date: Thu, 27 Aug 2015 17:09:27 +0000
Message-ID: <CALS8Sqg8HQVmHt2UOiLfRMmkHyzzD2G2nKGPhqnh=3hjKW=NOA@mail.gmail.com>
Subject: test
To: [email protected]
Content-Type: multipart/alternative; boundary=089e0158aea02abfcc051e4e0861
--089e0158aea02abfcc051e4e0861
Content-Type: text/plain; charset=UTF-8
--089e0158aea02abfcc051e4e0861
Content-Type: text/html; charset=UTF-8
<div dir="ltr"><br></div>
--089e0158aea02abfcc051e4e0861--
.
451 Local Error
502 5.5.1 Command ' by ' not implemented.
502 5.5.1 Command ' for' not implemented.
502 5.5.1 Command 'DKIM' not implemented.
502 5.5.1 Command ' t=1' not implemented.
502 5.5.1 Command ' h=F' not implemented.
502 5.5.1 Command ' b=G' not implemented.
502 5.5.1 Command ' 6F' not implemented.
502 5.5.1 Command ' G7' not implemented.
502 5.5.1 Command 'Rece' not implemented.
502 5.5.1 Command ' ' not implemented.
502 5.5.1 Command 'X-Re' not implemented.
502 5.5.1 Command ' Thu' not implemented.
502 5.5.1 Command 'MIME' not implemented.
502 5.5.1 Command 'From' not implemented.
502 5.5.1 Command 'Date' not implemented.
502 5.5.1 Command 'Mess' not implemented.
502 5.5.1 Command 'Subj' not implemented.
502 5.5.1 Command 'To: ' not implemented.
502 5.5.1 Command 'Cont' not implemented.
501 Command too short.
502 5.5.1 Command '--08' not implemented.
502 5.5.1 Command 'Cont' not implemented.
501 Command too short.
501 Command too short.
501 Command too short.
502 5.5.1 Command '--08' not implemented.
502 5.5.1 Command 'Cont' not implemented.
501 Command too short.
502 5.5.1 Command '<div' not implemented.
501 Command too short.
502 5.5.1 Command '--08' not implemented.
501 Command too short.
QUIT
Why the foreign server doesn't understand the communication? I don't see anything bad in it.
Solution 1:
The recipient's mailserver gives you the clue:
451 Local Error
This means that their server is having a problem and you should try back later.
From your log, it appears likely that their mailserver flaked out after receiving the first line of the email content, and that every line in the email after that was interpreted as a new command - which failed, since they're not valid SMTP commands.
I'm guessing that you did a copy-paste of the email contents; if you'd pasted one line at a time instead of the entire email, you would have gotten the error message immediately after that first line, and you would not have gotten the rest of the error messages, which would have made the problem a lot clearer.
Since it's their mailserver that is having the issue, not yours, there's nothing you can do to fix it. You'll have to wait, or possibly phone them.
Solution 2:
It seems to be a CR+LF problem. Are you sure you send both control characters for end of lines in DATA? Not every MTA is sensitive to this, AFAIK.
I don't think it's Postfix where the change should be made, but rather an original application (the one generating message). Try saving the message in a UNIX (LF-only) file, then run cat file |sendmail -i -t
, next convert the file to DOS format (CR+LF) with todos file
, then again cat file |sendmail -i -t
. Check mail logs. This test should tell you whether the problem lies here.