camscape - for excellent IT solutions itkb.ro - IT knowledge base

linux :: remote host said: 503 but you already said helo

Cristian
Cristian M.
TitleRemote host said: 503 but you already said HELO
Tagsemail server, 503, already said HELO
Desc.Remote host said: 503 but you already said HELO
CodeKBLN0003 v1.0
Date25 septembrie 2012
In anumite cazuri, serverele e-mail nu implementeaza corect sau in totalitate RFC 2821 (http://www.ietf.org/rfc/rfc2821.txt) si/sau RFC 3207 (http://www.ietf.org/rfc/rfc3207.txt).

Cel mai des intalnit caz este cand aceste servere nu folosesc EHLO ci doar HELO si, conform RFC-urilor mai sus mentionate, in cazul in care la EHLO nu se raspunde, trebuie trimis intai un RSET dupa care se incearca HELO. Mesajul de eroare primit in acest caz este:

Remote host said: 503 but you already said HELO

Mai jos este prezentat un patch pentru qmail (http://www.qmail.org). Patch-ul introduce comanda RSET intre cele doua comenzi EHLO si HELO. Deasemenea, unele dintre aceste servere nu implementeaza nici macar comanda RSET, motiv pentru care, in patch-ul prezentat, se trateaza doar cu log nu si cu hardfail.

Patch 30-reset-between-helo-and-ehlo.patch:

RSET command between EHLO and HELO

This patch sends a RSET command before trying to issue a HELO command, when
initial EHLO fails.

Also, make only one call to ehlo() if not SMTPS and tls_init().

Declares a conditional DEBUG, useful if transactions are to be studied. It
is commented by default, comment it out and recompile to use it.

All these are needed on some buggy remote servers (or buggy connections).

Copyright: CAMSCAPE SERVICES SRL
Version: 0.0.3
Release: 24.09.2012
Web: www.camscape.ro/opensource

--- qmail-remote.c.orig 2011-12-25 07:10:08.000000000 +0200
+++ qmail-remote.c      2011-12-25 07:11:46.000000000 +0200
@@ -30,6 +30,8 @@
 #include "timeoutwrite.h"
 #include "base64.h"

+//#define DEBUG 1
+
 #define HUGESMTPTEXT 5000

 #define PORT_SMTP 25 /* silly rabbit, /etc/services is for users */
@@ -720,15 +722,13 @@

 # ifdef TLS
   if (!smtps)
-    code = ehlo();
-# endif
-
-# ifdef TLS
-  if (tls_init())
-    /* RFC2487 says we should issue EHLO (even if we might not need
-     * extensions); at the same time, it does not prohibit a server
-     * to reject the EHLO and make us fallback to HELO */
-    code = ehlo();
+  {
+    if (tls_init())
+      /* RFC2487 says we should issue EHLO (even if we might not need
+       * extensions); at the same time, it does not prohibit a server
+       * to reject the EHLO and make us fallback to HELO */
+      code = ehlo();
+  }
 # endif

   substdio_puts(&smtpto,"EHLO ");
@@ -737,6 +737,12 @@
   substdio_flush(&smtpto);

   if (smtpcode() != 250) {
+    substdio_puts(&smtpto,"RSET ");
+    substdio_puts(&smtpto,"\r\n");
+    substdio_flush(&smtpto);
+    code = smtpcode();
+    if (code != 250) out("ZTrying to reset but failed ");
+
     substdio_puts(&smtpto,"HELO ");
     substdio_put(&smtpto,helohost.s,helohost.len);
     substdio_puts(&smtpto,"\r\n");