Fall back to HELO when remote server doesn't understand EHLO
[mgsmtp.git] / Relay.pas
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);