Forum > Networking and Web Programming

Indy10 TIdSMTP with SSL fails on RaspberryPi

(1/1)

BosseB:
I have ported a Delphi application (service non-gui type) to FreePascal 3.2.0/Lazarus 2.0.12 on a Raspberry Pi3 with Raspbian Linux and I am now checking all of the functionality.
Yesterday I found that the built-in emailing on certain events failed...

It turns out that the Indy10 TIdSMTP class when running through an SSL connection fails to load the SSL library...
It has been discussed here before, but I found that the "solution" to use FPC 3.2.0 seems not to apply to a RaspberryPi installation (as I said above I use 3.2.0)...

I get this in the logfile the application writes:

--- Code: Text  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---20210505 04:40:37.612 ERROR: Exception during email send: Could not load SSL library.20210505 04:40:37.613 ERROR: Failed to send start mail message20210505 04:42:39.491 ERROR: Exception during email send: Could not load SSL library.20210505 04:42:39.492 ERROR: Failed to send finish mail message

Below is an abbreviated version of the code:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---function TSSRemoteServer.SendMailMessage(Subject: string; BodyText, AttachedFiles: TStrings;): boolean;var  IdSendMail: TIdSMTP;  IdMessage: TIdMessage;  SSLHandlerSmtp: TIdSSLIOHandlerSocketOpenSSL;  ...begin  Result := false;  IdSendMail := TIdSMTP.Create(NIL);  IdMessage := TIdMessage.Create(NIL);  SSLHandlerSmtp := TIdSSLIOHandlerSocketOpenSSL.Create(NIL);  try    try      IdSendMail.Host := FEmailServer;      IdSendMail.Port := FEmailPort; //Added 2021-05-05       if FEmailAuth then      begin        IdSendMail.AuthType := IdSmtp.satDefault;        IdSendMail.UserName := FEmailUser;        IdSendMail.Password := FEmailPwd;      end      else      begin        IdSendMail.AuthType := IdSmtp.satNone;        IdSendMail.UserName := '';        IdSendMail.Password := '';      end;       if FEmailSSL then  //Added 2021-05-05 to handle the encrypted email send      begin        IdSendMail.IOHandler := SSLHandlerSmtp;        IdSendMail.UseTLS := utUseImplicitTLS;        SSLHandlerSmtp.Port := FEmailPort;      end;      IdSendMail.MailAgent := 'Remote Server';      IdMessage.IsEncoded := true;      IdMessage.Subject := Subject;      IdMessage.From.Text := FEmailSender;      IdMessage.Body.Text := BodyText.Text;       if AttachedFiles.Count > 0 then      begin        LogStd('Attachment count: ' + IntToStr(AttachedFiles.Count));        {Attach each file in the list to the message}        for i := 0 to AttachedFiles.Count -1 do        begin          sTmp := AttachedFiles[i];          if FileExists(sTmp) then            with TIdAttachmentFile.Create(IdMessage.MessageParts, sTmp) do            begin              ContentType := 'application/x-zip-compressed';            end;        end;      end;      {Now send}      LogStd('Message prepared, now send mail');      try        bSendOK := false;        IdSendMail.Connect;        if IdSendMail.Connected then        begin          try            IdSendMail.Send(IdMessage);            bSendOK := true;          finally            IdSendMail.Disconnect;          end;          if bSendOK then          begin            Result := true;            LogStd('Mail message sent. Subject: ' + Subject);          end;        end;      except        on E: Exception do          LogErr('Exception during email send: ' + E.Message);      end;    except      on E: Exception do        LogErr('Exception in TSSRemoteServer.SendMailMessage: ' + E.Message);    end;  finally    IdSendMail.Free;    IdMessage.Free;    SSLHandlerSmtp.Free;  end;end; 

Remy Lebeau:

--- Quote from: BosseB on May 05, 2021, 04:15:59 pm ---It turns out that the Indy10 TIdSMTP class when running through an SSL connection fails to load the SSL library...

--- End quote ---

I just answered your same post on Indy's forum.

In a nutshell, your Pi is using OpenSSL 1.1.1, which TIdSSLIOHandlerSocketOpenSSL does not support.  Try this experimental SSLIOHandler for OpenSSL 1.1.1 (I don't know if it works on Linux/Pi).

Navigation

[0] Message Index

Go to full version