1

Using Delphi, Intraweb, Indy. There are no problems sending an email (SMTP) in the IDE (runtime). But I get the error: "SSL Negotiation failed" using an ISAPI-dll while trying to Authenticate. libeay32.dll and ssleay32.dll are in the same directory as the ISAPI-dll.

Any ideas? Thanks, Andreas

function NetSendMail(cTo, cSubject, cBody: String; cFrom: String = ''): Boolean;
var
  oIdSMTP: TIdSMTP;
  oIdMessage: TIdMessage;
  oIdSSLIOHandler: TIdSSLIOHandlerSocketOpenSSL;
begin
  result := False;

  oIdSMTP := nil;
  oIdMessage := nil;
  try
    oIdSSLIOHandler := TIdSSLIOHandlerSocketOpenSSL.Create(Application);
    oIdSSLIOHandler.SSLOptions.Mode := sslmClient;
    oIdSMTP := TIdSMTP.Create(Application);
    oIdSMTP.IOHandler := oIdSSLIOHandler;
    oIdSMTP.UseTLS := utUseExplicitTLS;
    oIdSMTP.Host     := 'smtp.strato.de';
    oIdSMTP.Port     := 587;
    oIdSMTP.Username := '***';
    oIdSMTP.Password := '***';

    oIdMessage := TIdMessage.Create(Application);
    with oIdMessage do
    begin
      Recipients.Add().Address := cTo;
      Subject := cSubject;
      Body.Add(cBody);

      if cFrom <> '' then
        From.Address := cFrom
      else
        From.Address := 'absender@sesamsoft.de';
    end;
    with oIdSMTP do
      try
        AuthType := satDefault;
        try
          if not Connected() then
            Connect();
        except
          on E: Exception do
          begin
            MsgShowMessage('Connect: ' + E.Message);
            result := False;
            exit;
          end;
        end;
        try
          Authenticate;
        except
          on E: Exception do
          begin
            MsgShowMessage('Auth: ' + E.Message);
            result := False;
            exit;
          end;
        end;

        if not Connected() then
          Connect();
        Send(oIdMessage);
      except
        on E: Exception do
        begin
          MsgShowMessage(E.Message);
          result := False;
          exit;
        end;
      end;
  finally
    oIdSMTP.Disconnect;

    FreeAndNil(oIdSMTP);
    FreeAndNil(oIdMessage);
    FreeAndNil(oIdSSLIOHandler);
  end;

  result := True;
end;

The answert couldn't help me. I included the code I'm using. It works fine with a "normal" desktop application. And it works aswell with INTRAWEB in runtime but not in the final ISAPI-dll. – Andreas

Andreas
  • 11
  • 3
  • It would help if you provided some of the code. Just saying "using ISAPI-dll" does not give us any clue as to what you are doing and where things are going wrong. – Sam Apr 03 '19 at 15:15
  • The only difference running in runtime or ISAPI.dll is IIS. Maybe there is the problem. All works fine with port 25 but not with 687. – Andreas Apr 08 '19 at 11:35
  • Sorry, not 687 but 587 – Andreas Apr 08 '19 at 12:15
  • Solved! libeay32.dll and ssleay32.dll have to be placed in windows\system32 Thaks anyway – Andreas Apr 12 '19 at 14:48

0 Answers0