Quantcast
Channel: Atozed Forums - All Forums
Viewing all articles
Browse latest Browse all 275

IdSMTP failed to connect using SSL

$
0
0
Back in 2018-2019 I wrote a commit emailer for our SVN server using Lazarus/FPC and Indy 10.6.2.
It retrieves the data from SVN and packages it into a message sent to the subscribed developers using a mailserver on my ISP.
I have created a specific email account on the ISP for this purpose and this requires SSL login for sending which is done using the code below.

The mailer has worked flawlessly for all the time since then until mid-December 2023 when the emails stopped coming.
Now I have finally found the logfiles for the mailer and this is what is reported upon each sending:
Code:
20240111 17:13:35.343 Connecting to mailserver
20240111 17:13:36.590 EXCEPTION: In SendSvnMessage = Error connecting with SSL.
error:1409442E:SSL routines:ssl3_read_bytes:tlsv1 alert protocol version

So it seems to be a problem with SSL negotiations here and now I am at a loss as to where I can start finding the reason for this and a solution.

The actual code where the sending is done looks like this:

Code:
constructor TSvnMessage.Create;
begin
  FSvnUsers := TSvnUsers.Create;
  FSubscription := TStringList.Create;
  FSMTP := TIdSMTP.Create(nil);
  FSSLHandler := TIdSSLIOHandlerSocketOpenSSL.Create(nil);
  FMailMessage := TIdMessage.Create(nil);
end;

function TSvnMessage.SendSvnMessage: boolean;
var
  sSubject: string;
  i: integer;
begin
  Result := false;
  try
    PrepareMessage;
    if (FMailMessage.Sender.Address = '') and (FMailMessage.From.Address = '') then
    begin
      LogError('No sender! Cannot send email!');
      exit;
    end;
    if FMailMessage.Recipients.Count = 0 then
    begin
      LogError('No recipients! Cannot send email!');
      exit;
    end;
    //Set up the SMTP transfer properties
    FSMTP.Port := FMailPort;
    FSMTP.Host := FMailServer;
    FSMTP.AuthType := satDefault;
    FSMTP.Username := FMailLogin;
    FSMTP.Password := FMailPwd;
    FSMTP.MailAgent := 'SVNMailer';
    if FMailUseSSL then
    begin
      FSMTP.IOHandler := FSSLHandler;
      FSMTP.UseTLS := utUseImplicitTLS;
      FSSLHandler.Port := FMailPort;
    end;
    FSMTP.ConnectTimeout := FMailTimeout;

    //Check message subject for illegal chars
    if Length(FMailMessage.Subject) &t 76 then
    begin
      sSubject := FMailMessage.Subject;
      for i := 1 to Length(sSubject) do
      begin
        if Ord(sSubject[i]) &t 127 then
          sSubject[i] := '?';
      end;
      FMailMessage.Subject := sSubject;
    end;

    //Now send message
    Log('Connecting to mailserver');
    FSMTP.Connect;
    if FSMTP.Connected then
    begin
      Log('Sending message');
      FSMTP.Send(FMailMessage);
      Log('Send done');
      FSMTP.Disconnect();
      Result := true;
    end;
  except
    on E: Exception do
    begin
      LogException('In SendSvnMessage = ' + E.Message);
    end;
  end;
end;

Since it has worked for these many years there must be some change either in the Windows Server 2016 where it runs or else in the mail server configuration, but where should I start looking?

For instance if the mail server requires a later version of SSL, how can I fix that in my program?

Note:
This is the same problem I was looking for a work-around to and asked here about earlier.
See thread Change report from send email to post to a php handler
I'd rather have the modification done in the existing mailer than going that route, though...

Viewing all articles
Browse latest Browse all 275

Trending Articles