(Relay) Minor optimization to TRelayer.OpenConnection
[mgsmtp.git] / Relay.pas
index cf3876027bef390a883e18f7771258ceced65416..bcbcc9d92ee6842c5de66b050df69c6890e949e1 100644 (file)
--- a/Relay.pas
+++ b/Relay.pas
@@ -1,6 +1,6 @@
 {
    MegaBrutal's SMTP Server (MgSMTP)
-   Copyright (C) 2010-2015 MegaBrutal
+   Copyright (C) 2010-2018 MegaBrutal
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as published by
@@ -331,9 +331,10 @@ var MXList: TStrings; i: integer;
 begin
    MXList:= GetCorrectMXRecordList(RelayServerName);
    if MXList.Count >= 1 then begin
-      TCP:= TTCPRFCConnection.Create(MXList.Strings[0], RelayServerPort);
+      TCP:= TTCPRFCConnection.Create;
+      TCP.SetBindAddress(MainServerConfig.BindAddress);
       TCP.SetSockTimeOut(DEF_SOCK_TIMEOUT);
-      i:= 1;
+      i:= 0;
       while (not TCP.Connected) and (i < MXList.Count) do begin
          TCP.Connect(MXList.Strings[i], RelayServerPort);
          Inc(i);