Recent

Author Topic: Can't Install Indy Packages or Send Email By SMTP  (Read 1021 times)

AaronCatolico1

  • New Member
  • *
  • Posts: 23
Can't Install Indy Packages or Send Email By SMTP
« on: November 08, 2024, 05:35:58 am »
I've been trying to install Indy SMTP and required packages. I keep getting error messages as shown in the image below.

Does anyone have any instructions on how to ensure the Indy packages will be installed properly and how to send a basic email with it?

I tried to install the Indy SMTP server and error messages appeared while using the Lazarus Package Manager installation wizard. I'm not quite sure what these errors are or how to fix this issue. I've even put the Indy folder directly inside of the project folder to no avail.

My emailing code:
Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls,
  9.   IdSMTP, IdMessage, IdSSL, IdSSLOpenSSL;
  10.  
  11. type
  12.  
  13.   { TForm1 }
  14.  
  15.   TForm1 = class(TForm)
  16.     Button1: TButton;
  17.     procedure Button1Click(Sender: TObject);
  18.   private
  19.  
  20.   public
  21.  
  22.   end;
  23.  
  24. var
  25.   Form1: TForm1;
  26.  
  27. implementation
  28.  
  29. {$R *.lfm}
  30.  
  31. { TForm1 }
  32.  
  33. procedure TForm1.Button1Click(Sender: TObject);
  34. var
  35.   SMTP: TIdSMTP;
  36.   Email: TIdMessage;
  37. begin
  38.    SMTP := TIdSMTP.Create(nil);
  39.   Email := TIdMessage.Create(nil);
  40.   try
  41.     SMTP.Host := 'smtp.example.com';
  42.     SMTP.Port := 587;
  43.     SMTP.Username := 'your_username';
  44.     SMTP.Password := 'your_password';
  45.     SMTP.IOHandler := TIdSSLIOHandlerSocketOpenSSL.Create(SMTP);
  46.     SMTP.UseTLS := utUseExplicitTLS;
  47.  
  48.     Email.From.Address := 'you@example.com';
  49.     Email.Recipients.EmailAddresses := 'recipient@example.com';
  50.     Email.Subject := 'Test Email';
  51.     Email.Body.Text := 'This is a test email sent using Indy components.';
  52.  
  53.     SMTP.Connect;
  54.     SMTP.Send(Email);
  55.     SMTP.Disconnect;
  56.   finally
  57.     SMTP.Free;
  58.     Email.Free;
  59.   end;
  60. end;
  61.  
  62. end.
  63.  
  64.  
« Last Edit: November 08, 2024, 05:59:08 pm by AaronCatolico1 »

carl_caulkett

  • Hero Member
  • *****
  • Posts: 649
Re: Can't Install Indy Packages or Send Email By SMTP
« Reply #1 on: November 08, 2024, 08:15:18 pm »
Hi Aaron,

What version of FPC and Lazarus? How were they installed - from the downloaded installers or from FpcUpDeluxe? And what OS and version number? I assume Windows from the screen shot.
These details can help to narrow down the options!
« Last Edit: November 08, 2024, 08:18:26 pm by carl_caulkett »
"It builds... ship it!"

Remy Lebeau

  • Hero Member
  • *****
  • Posts: 1430
    • Lebeau Software
Re: Can't Install Indy Packages or Send Email By SMTP
« Reply #2 on: November 08, 2024, 08:41:05 pm »
I commented on your same question on StackOverflow:
https://stackoverflow.com/questions/79170938/not-able-to-install-indy-in-lazarus-ide

Quote
I know for a fact that the Indy in OPM works fine (albeit a few versions behind Indy's GitHub version). The .o files that are failing are Zlib files, and while Indy does use them, it does not load them from the path in the error messages. As for utUseExplicitTLS, it is declared in the IdExplicitTLSClientServerBase unit
Remy Lebeau
Lebeau Software - Owner, Developer
Internet Direct (Indy) - Admin, Developer (Support forum)

AaronCatolico1

  • New Member
  • *
  • Posts: 23
Re: Can't Install Indy Packages or Send Email By SMTP
« Reply #3 on: November 08, 2024, 09:35:45 pm »
Lazarus 3.6 and FPC 3.2.2.
I used the downloaded installers, not FPCUpDeluxe.
OS is Windows 11 64-bit.


Hi Aaron,

What version of FPC and Lazarus? How were they installed - from the downloaded installers or from FpcUpDeluxe? And what OS and version number? I assume Windows from the screen shot.
These details can help to narrow down the options!

carl_caulkett

  • Hero Member
  • *****
  • Posts: 649
Re: Can't Install Indy Packages or Send Email By SMTP
« Reply #4 on: November 08, 2024, 09:46:12 pm »
Lazarus 3.6 and FPC 3.2.2.
I used the downloaded installers, not FPCUpDeluxe.
OS is Windows 11 64-bit.


Hi Aaron,

What version of FPC and Lazarus? How were they installed - from the downloaded installers or from FpcUpDeluxe? And what OS and version number? I assume Windows from the screen shot.
These details can help to narrow down the options!

Best you deal with Remy on this one; he's one of the Indy developers, I believe! BTW, the OPM that Remy talks about in his answers, refers to the Online Package Manager, which first needs to be installed from the Package -> Install/Uninstall Packages option, followed by an IDE rebuild. That should then put an extra Online Package Manager option on your Package menu option. Just install Indy from there 😉
"It builds... ship it!"

AaronCatolico1

  • New Member
  • *
  • Posts: 23
Re: Can't Install Indy Packages or Send Email By SMTP
« Reply #5 on: November 08, 2024, 09:58:36 pm »
I did use the OPM, as well as dumped the whole folder into my project. Still results in same errors.

Lazarus 3.6 and FPC 3.2.2.
I used the downloaded installers, not FPCUpDeluxe.
OS is Windows 11 64-bit.


Hi Aaron,

What version of FPC and Lazarus? How were they installed - from the downloaded installers or from FpcUpDeluxe? And what OS and version number? I assume Windows from the screen shot.
These details can help to narrow down the options!

Best you deal with Remy on this one; he's one of the Indy developers, I believe! BTW, the OPM that Remy talks about in his answers, refers to the Online Package Manager, which first needs to be installed from the Package -> Install/Uninstall Packages option, followed by an IDE rebuild. That should then put an extra Online Package Manager option on your Package menu option. Just install Indy from there 😉

AaronCatolico1

  • New Member
  • *
  • Posts: 23
Re: Can't Install Indy Packages or Send Email By SMTP
« Reply #6 on: November 09, 2024, 01:04:15 am »
I managed to re-install everything through FPCupDeluxe and file path directories are all fixed with the new installation, however, I am still getting the error message with the "utUseExplicitTLS". What exactly did you mean by it is declared in the IdExplicitTLSClientServerBase unit? How do I do this exactly?

Here's what it's showing now in the image below (as shown below and in the image):
"unit1.pas(51,20) Error: Identifier not found "utUseExplicitTLS""


Quote
I know for a fact that the Indy in OPM works fine (albeit a few versions behind Indy's GitHub version). The .o files that are failing are Zlib files, and while Indy does use them, it does not load them from the path in the error messages. As for utUseExplicitTLS, it is declared in the IdExplicitTLSClientServerBase unit
« Last Edit: November 09, 2024, 01:05:47 am by AaronCatolico1 »

Remy Lebeau

  • Hero Member
  • *****
  • Posts: 1430
    • Lebeau Software
Re: Can't Install Indy Packages or Send Email By SMTP
« Reply #7 on: November 09, 2024, 01:19:55 am »
however, I am still getting the error message with the "utUseExplicitTLS".

I already addressed that in my first comment.

What exactly did you mean by it is declared in the IdExplicitTLSClientServerBase unit? How do I do this exactly?

Simply add that unit to the uses clause in your code, same as any other Pascal unit you want to use things from, eg:

Code: [Select]
uses
  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls,
  IdExplicitTLSClientServerBase, IdSMTP, IdMessage, IdSSL, IdSSLOpenSSL;
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
« Last Edit: November 09, 2024, 02:46:46 am by Remy Lebeau »
Remy Lebeau
Lebeau Software - Owner, Developer
Internet Direct (Indy) - Admin, Developer (Support forum)

AaronCatolico1

  • New Member
  • *
  • Posts: 23
Re: Can't Install Indy Packages or Send Email By SMTP
« Reply #8 on: November 09, 2024, 05:09:14 am »
I have added the clause to the code, but now I keep receiving these two error messages as shown in the images I've attached here:





Simply add that unit to the uses clause in your code, same as any other Pascal unit you want to use things from, eg:

Code: [Select]
uses
  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls,
  IdExplicitTLSClientServerBase, IdSMTP, IdMessage, IdSSL, IdSSLOpenSSL;
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
[/quote]

AaronCatolico1

  • New Member
  • *
  • Posts: 23
Re: Can't Install Indy Packages or Send Email By SMTP
« Reply #9 on: November 09, 2024, 06:32:35 am »
I finally got. The problem was that I didn't know I was supposed to download and add the OpenSSL dll files directly in the project. Everything seems to be working now! Thanks again, though, Remy!

AaronCatolico1

  • New Member
  • *
  • Posts: 23
Re: Can't Install Indy Packages or Send Email By SMTP
« Reply #10 on: November 10, 2024, 01:16:31 am »
How do I attach image files to the email? I've created a listbox that stores the images, loads images with openfiledialog, but not sure how to submit the images from there. Do I need to use all 3 of these; IdAttachmentFile, IdMessageParts, & IdAttachment in the uses clause?

Code: Pascal  [Select][+][-]
  1. // Configure the OpenDialog settings
  2.   OpenDialog1.Title := 'Select Image(s)';
  3.   OpenDialog1.Filter := 'Image Files|*.jpg;*.jpeg;*.png;*.bmp;*.gif|All Files|*.*';
  4.   OpenDialog1.Options := OpenDialog1.Options + [ofAllowMultiSelect];
  5.  
  6.   // Execute the OpenDialog
  7.   if OpenDialog1.Execute then
  8.   begin
  9.     // Loop through the selected files and add their paths to the list box
  10.     for i := 0 to OpenDialog1.Files.Count - 1 do
  11.     begin
  12.       ListBox1.Items.Add(OpenDialog1.Files[i]);
  13.     end;
  14.   end;
  15.  






Quote
Simply add that unit to the uses clause in your code, same as any other Pascal unit you want to use things from, eg:

Code: [Select]
uses
  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls,
  IdExplicitTLSClientServerBase, IdSMTP, IdMessage, IdSSL, IdSSLOpenSSL;
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 

Remy Lebeau

  • Hero Member
  • *****
  • Posts: 1430
    • Lebeau Software
Re: Can't Install Indy Packages or Send Email By SMTP
« Reply #11 on: November 10, 2024, 02:35:16 am »
How do I attach image files to the email?


Add a TIdAttachmentFile object to the TIdMessage.MessageParts collection. I suggest you read the following articles on Indy's blog:

https://www.indyproject.org/2005/08/17/html-messages/

https://www.indyproject.org/2008/01/16/new-html-message-builder-class/

Do I need to use all 3 of these; IdAttachmentFile, IdMessageParts, & IdAttachment in the uses clause?

IdAttachmentFile will suffice. You don't need the other two unless you are declaring your own variables of those types.
Remy Lebeau
Lebeau Software - Owner, Developer
Internet Direct (Indy) - Admin, Developer (Support forum)

AaronCatolico1

  • New Member
  • *
  • Posts: 23
Re: Can't Install Indy Packages or Send Email By SMTP
« Reply #12 on: November 11, 2024, 12:58:39 am »
Thanks again, Remy! You've helped me greatly, as usual!

 

TinyPortal © 2005-2018