Indy 10 and Xmailer : "Could Not Load SSL Library" or "SSL Error"

99 Views Asked by At

I am writing a program on Ubuntu that will send email on the Internet.

I am testing 2 tools/components to see which one works, but every time I try to send an email from my program, I get an error as follows.

For Indy 10:

procedure TForm1.Button1Click(Sender: TObject);
begin
   SMTP.Host := 'smtp.gmail.com';  //  smtp.gmail.com is here
   SMTP.Port := 465;
   SMTP.AuthType:=satDefault;

   SMTP.UserName:='myemailaddress';
   SMTP.Password:='**** **** **** ****'; //<<<<< App Password

   //setup mail message
   MailMessage.From.Address := '[email protected]';
   MailMessage.Recipients.EMailAddresses := '[email protected]';
   MailMessage.Subject := 'Amazon Order';
   MailMessage.Body.Text := 'Hey, Your Amazon order is delivered.';

   //send mail
   try
      try
         SMTP.Connect;
         SMTP.Send(MailMessage);
      except on E:Exception do
         showmessage('ERROR: ' + E.Message);
      end;
      finally
         if SMTP.Connected then SMTP.Disconnect;
      end;
end;

When I execute the above code, I get the following error:

ERROR: Could not load SSL Library

image

For XMailer:

procedure TForm1.FormCreate(Sender: TObject);
begin
   IdOpenSSLSetLibPath('/home/bobby/testingemail/');
end;

procedure TForm1.Button2Click(Sender: TObject);
var
   Mail: TSendMail;
begin
   Mail := TSendMail.Create;
   try
      // Mail
      Mail.Sender := 'myemailaddress <[email protected]>';
      Mail.Receivers.Add('[email protected]');
      Mail.Subject := 'Amazon order';
      Mail.Message.Add('Hey, Your Amazon order is delivered.');

      // SMTP
      Mail.Smtp.UserName := 'myemailaddress';
      Mail.Smtp.Password := '**** **** **** ****';  //<<<< App Password
      Mail.Smtp.Host := 'smtp.gmail.com';
      Mail.Smtp.Port := '587';
      mail.Smtp.FullSSL:=false;
      Mail.Smtp.TLS := True;

      Mail.Send;
      ShowMessage('SUCCESS :) ');
   finally
      Mail.Free;
 end;
end;

When I execute the above code for XMailer, I get the following error:

SSL Error:TSendmail.

image

So, I found an info on this error on a website and followed their instructions.

  1. Downloaded openssl-1.0.2u, extracted tar file, ran ./config and make terminal commands.

  2. Then, copied and pasted the following files into my project folder (libcrypto.so and libssl.so).

    image

After that, I rebooted my computer and tested my program, but I still get the same error Can't load SSL Library.

Any idea?

0

There are 0 best solutions below