Fall back to HELO when remote server doesn't understand EHLO
authorMegaBrutal <code+git@megabrutal.com>
Sun, 8 Feb 2015 05:35:58 +0000 (06:35 +0100)
committerMegaBrutal <code+git@megabrutal.com>
Sun, 8 Feb 2015 05:35:58 +0000 (06:35 +0100)
modified:   MgSMTP.pas
modified:   Relay.pas
modified:   todo.txt

MgSMTP.pas
Relay.pas
todo.txt

index 3e6ddfb2978f89ca0fd4b3f6b2982a922dec824c..181d969171d98cc44c1173ade478ec05d23ff81e 100644 (file)
@@ -49,7 +49,7 @@ const
      document what bugfix/feature are you testing with the actual build.
      This will be logged to help you differentiate outputs of subsequent
      builds in your logs. If left empty, it won't be added to the logs. }
-   DEVCOMMENT  =  'Escaping dots';
+   DEVCOMMENT  =  'EHLO->HELO fallback';
 
 var
 
index 1e42979d761b9401daa8cbd342b45dc326330b76..cea792d52c5237a026db4f17fb390c413e16fd1f 100644 (file)
--- a/Relay.pas
+++ b/Relay.pas
@@ -377,7 +377,14 @@ begin
          end;
          Result:= true;
       end
-      else AdministerMassFailure(Result);
+      else if (Response.GetNumericCode >= 500) and (Response.GetNumericCode <= 504) then begin
+         { It seems the remote site did not understand our EHLO, that is,
+           let's admit, quite odd in the 21st century...
+           Whatever, let's fall back to RFC 821 then. }
+         TCP.SendCommand(SMTP_C_HELO, MainServerConfig.Name);
+         TCP.ReadResponse(Response);
+         Result:= Response.GetNumericCode = SMTP_R_OK;
+      end;
 
       if Result then begin
          if FRoutingTarget.Auth then begin
@@ -408,7 +415,8 @@ begin
          else Authenticated:= true;
 
          if not Authenticated then AdministerMassFailure(Result);
-      end;
+      end
+      else AdministerMassFailure(Result);
 
    end
    else AdministerMassFailure(Result);
index 3c871a05121c0fa0eb30e1412685a89bd60184ac..58ac308782db2a5cdb27d576a4a94560d022b669 100644 (file)
--- a/todo.txt
+++ b/todo.txt
@@ -27,8 +27,9 @@ v0.9t:
 - Bind to user-specified IPs
 + Option to add Reply-To header to forwarded e-mails
 + Fix non-RFC-compliant handling of lines starting with dots
-- Fall back to HELO when remote server doesn't support EHLO
++ Fall back to HELO when remote server doesn't support EHLO
 - Implement CHUNKING extension
+- Implement more proper reactions for non-standard replies and sequence breaking
 
 v0.9s:
 + Change "Client disconnected, and thread exited successfully." to "Client disconnected."