Discussion:
[fpc-pascal] Dependency of OpenSSL 1.0.2 still in FPC 3.2.0 on some platforms?
Bo Berglund via fpc-pascal
2021-05-05 14:33:52 UTC
Permalink
I have an application which is ported from Delphi to FreePascal and will be used
on Raspberry Pi (Debian based Linux).
It uses Indy10 components. Indy is installed using OnLinePackageManager in
Lazarus.

The problem I have is that when I run the application it gets an exception when
trying to send an email via an SSL encrypted SMTP mail server.

The exception log I have shows this:
ERROR: Exception during email send: Could not load SSL library.

When searching for this problem I found a Lazarus forum thread dealing in the
same, where a openssl version clash is the reason:
https://forum.lazarus.freepascal.org/index.php/topic,48974.msg354212.html#msg354212

This post states that the problem is solved in FPC 3.2.0

The core of the problem seems to be the openssl version clash...

Any ideas on how to solve this on Pi-OS Linux?
--
Bo Berglund
Developer in Sweden

_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/list
Michael Van Canneyt via fpc-pascal
2021-05-05 14:37:57 UTC
Permalink
Post by Bo Berglund via fpc-pascal
I have an application which is ported from Delphi to FreePascal and will be used
on Raspberry Pi (Debian based Linux).
It uses Indy10 components. Indy is installed using OnLinePackageManager in
Lazarus.
The problem I have is that when I run the application it gets an exception when
trying to send an email via an SSL encrypted SMTP mail server.
ERROR: Exception during email send: Could not load SSL library.
When searching for this problem I found a Lazarus forum thread dealing in the
https://forum.lazarus.freepascal.org/index.php/topic,48974.msg354212.html#msg354212
This post states that the problem is solved in FPC 3.2.0
If you are using Indy, it is not.
Post by Bo Berglund via fpc-pascal
The core of the problem seems to be the openssl version clash...
Any ideas on how to solve this on Pi-OS Linux?
You can't. Indy does not work with openssl 1.1.
You must install an older openssl library if you wish to work with Indy.

Michael.
_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/f
Nico Neumann via fpc-pascal
2021-05-05 14:46:20 UTC
Permalink
Indy has support for OpenSSL 1.1.1, just not officially (yet).
See https://github.com/IndySockets/Indy/pull/299

Am Mi., 5. Mai 2021 um 16:38 Uhr schrieb Michael Van Canneyt via fpc-pascal
Post by Bo Berglund via fpc-pascal
Post by Bo Berglund via fpc-pascal
I have an application which is ported from Delphi to FreePascal and will
be used
Post by Bo Berglund via fpc-pascal
on Raspberry Pi (Debian based Linux).
It uses Indy10 components. Indy is installed using OnLinePackageManager
in
Post by Bo Berglund via fpc-pascal
Lazarus.
The problem I have is that when I run the application it gets an
exception when
Post by Bo Berglund via fpc-pascal
trying to send an email via an SSL encrypted SMTP mail server.
ERROR: Exception during email send: Could not load SSL library.
When searching for this problem I found a Lazarus forum thread dealing
in the
https://forum.lazarus.freepascal.org/index.php/topic,48974.msg354212.html#msg354212
Post by Bo Berglund via fpc-pascal
This post states that the problem is solved in FPC 3.2.0
If you are using Indy, it is not.
Post by Bo Berglund via fpc-pascal
The core of the problem seems to be the openssl version clash...
Any ideas on how to solve this on Pi-OS Linux?
You can't. Indy does not work with openssl 1.1.
You must install an older openssl library if you wish to work with Indy.
Michael.
_______________________________________________
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Michael Van Canneyt via fpc-pascal
2021-05-05 14:51:06 UTC
Permalink
Post by Nico Neumann via fpc-pascal
Indy has support for OpenSSL 1.1.1, just not officially (yet).
See https://github.com/IndySockets/Indy/pull/299
I am aware of this. Good luck getting that to work on linux.
It's a total mess and not nearly ready for production use.

In the end I simply installed an older version of openssl.

Michael.
_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailma
Bo Berglund via fpc-pascal
2021-05-05 19:18:36 UTC
Permalink
On Wed, 5 May 2021 16:51:06 +0200 (CEST), Michael Van Canneyt via fpc-pascal
Post by Michael Van Canneyt via fpc-pascal
Post by Nico Neumann via fpc-pascal
Indy has support for OpenSSL 1.1.1, just not officially (yet).
See https://github.com/IndySockets/Indy/pull/299
I am aware of this. Good luck getting that to work on linux.
It's a total mess and not nearly ready for production use.
In the end I simply installed an older version of openssl.
Any directions on how to accomplish this?

Or is there some other way in Lazaus for Linux to add a function to send an
email containing attachments (files with monitoring result data)?
THe SMTP server I use requires SSL on port 465.
I have only ever used Indy for things like this.
--
Bo Berglund
Developer in Sweden

_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/f
Michael Van Canneyt via fpc-pascal
2021-05-05 21:20:08 UTC
Permalink
Post by Bo Berglund via fpc-pascal
On Wed, 5 May 2021 16:51:06 +0200 (CEST), Michael Van Canneyt via fpc-pascal
Post by Michael Van Canneyt via fpc-pascal
Post by Nico Neumann via fpc-pascal
Indy has support for OpenSSL 1.1.1, just not officially (yet).
See https://github.com/IndySockets/Indy/pull/299
I am aware of this. Good luck getting that to work on linux.
It's a total mess and not nearly ready for production use.
In the end I simply installed an older version of openssl.
Any directions on how to accomplish this?
Or is there some other way in Lazaus for Linux to add a function to send an
email containing attachments (files with monitoring result data)?
THe SMTP server I use requires SSL on port 465.
I have only ever used Indy for things like this.
Use package laz_synapse (in online package manager), unit smtpsend.

I'm using it in FPC and Delphi even today.
In general, it works a lot easier/simpler than Indy.

Unless you need some weird/outdated protocols,
I highly recommend Synapse over Indy.

Michael.
_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.freepascal.
Bo Berglund via fpc-pascal
2021-05-06 11:54:14 UTC
Permalink
On Wed, 5 May 2021 23:20:08 +0200 (CEST), Michael Van Canneyt via fpc-pascal
Post by Michael Van Canneyt via fpc-pascal
Post by Bo Berglund via fpc-pascal
On Wed, 5 May 2021 16:51:06 +0200 (CEST), Michael Van Canneyt via fpc-pascal
Post by Michael Van Canneyt via fpc-pascal
Post by Nico Neumann via fpc-pascal
Indy has support for OpenSSL 1.1.1, just not officially (yet).
See https://github.com/IndySockets/Indy/pull/299
I am aware of this. Good luck getting that to work on linux.
It's a total mess and not nearly ready for production use.
In the end I simply installed an older version of openssl.
Any directions on how to accomplish this?
Or is there some other way in Lazaus for Linux to add a function to send an
email containing attachments (files with monitoring result data)?
THe SMTP server I use requires SSL on port 465.
I have only ever used Indy for things like this.
Use package laz_synapse (in online package manager), unit smtpsend.
I'm using it in FPC and Delphi even today.
In general, it works a lot easier/simpler than Indy.
Unless you need some weird/outdated protocols,
I highly recommend Synapse over Indy.
I had great troubles a year or so ago when I tried using some serial packages
based on synapse because they brought in GUI stuff that made it impossible to
compile a simple program aimed at running as a service on a server style linux
box...

And this application is precisely the one I am working on now (after having
replaced the LazSerial and SynSerial etc packages with a serial class I wrote
myself using the FPC built-in serial unit. And using Indy10 for the networking
parts since I have used that for some 20 years or so.

So only if the emailing synapse is guaranteed GUI-free can I use it.

I may even use some external program for mailing by using TProcess to run it....
But what? THere used to be something called sendmail or similar in Linux but
right now I cannot see it on my boxes. And I am uncertain if it can do SSL
logins and accept attachment files.

Anyway, I received a reply from Remy L concerning Indy and that there is a fix
for the oipenssl version available, which he has not tested. I will try to do
that test in the near future. It would (if working) require no extra coding in
my application just an update of Indy10 itself. :)
--
Bo Berglund
Developer in Sweden

_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listi
Michael Van Canneyt via fpc-pascal
2021-05-06 12:04:07 UTC
Permalink
Post by Bo Berglund via fpc-pascal
Post by Michael Van Canneyt via fpc-pascal
I highly recommend Synapse over Indy.
I had great troubles a year or so ago when I tried using some serial packages
based on synapse because they brought in GUI stuff that made it impossible to
compile a simple program aimed at running as a service on a server style linux
box...
Yes, because you were using the wrong package.

If you use the correct package (laz_synapse.lpk), there will be no issue.

See e.g. here:

https://sourceforge.net/p/synalist/code/HEAD/tree/trunk/

But you can install it using the Online package manager.

In the online package manager, DO NOT use the pl_synapsevs package.

You myst use the laz_synapse (Synapse 40.1) package.
It does not have GUI dependencies.

I use it myself in a headless FPC-created server running on linux, since many many
years, and use it in a Delphi-created server also running on linux, so I'm very
confident it works as described :-)

Michael.
_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-p
Bo Berglund via fpc-pascal
2021-05-06 12:39:45 UTC
Permalink
On Thu, 6 May 2021 14:04:07 +0200 (CEST), Michael Van Canneyt via fpc-pascal
Post by Michael Van Canneyt via fpc-pascal
Post by Bo Berglund via fpc-pascal
Post by Michael Van Canneyt via fpc-pascal
I highly recommend Synapse over Indy.
I had great troubles a year or so ago when I tried using some serial packages
based on synapse because they brought in GUI stuff that made it impossible to
compile a simple program aimed at running as a service on a server style linux
box...
Yes, because you were using the wrong package.
If you use the correct package (laz_synapse.lpk), there will be no issue.
https://sourceforge.net/p/synalist/code/HEAD/tree/trunk/
But you can install it using the Online package manager.
In the online package manager, DO NOT use the pl_synapsevs package.
You myst use the laz_synapse (Synapse 40.1) package.
It does not have GUI dependencies.
I use it myself in a headless FPC-created server running on linux, since many many
years, and use it in a Delphi-created server also running on linux, so I'm very
confident it works as described :-)
Michael.
Thanks, I will have a look!
--
Bo Berglund
Developer in Sweden

_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.f
Bo Berglund via fpc-pascal
2021-05-10 07:14:28 UTC
Permalink
On Thu, 6 May 2021 14:04:07 +0200 (CEST), Michael Van Canneyt via fpc-pascal
Post by Michael Van Canneyt via fpc-pascal
Post by Bo Berglund via fpc-pascal
Post by Michael Van Canneyt via fpc-pascal
I highly recommend Synapse over Indy.
I had great troubles a year or so ago when I tried using some serial packages
based on synapse because they brought in GUI stuff that made it impossible to
compile a simple program aimed at running as a service on a server style linux
box...
Yes, because you were using the wrong package.
If you use the correct package (laz_synapse.lpk), there will be no issue.
https://sourceforge.net/p/synalist/code/HEAD/tree/trunk/
But you can install it using the Online package manager.
In the online package manager, DO NOT use the pl_synapsevs package.
You myst use the laz_synapse (Synapse 40.1) package.
It does not have GUI dependencies.
I have now installed Synapse 40.1 in LKazarus 2.0.12 with Fpc 3.2.0
Post by Michael Van Canneyt via fpc-pascal
I use it myself in a headless FPC-created server running on linux, since many many
years, and use it in a Delphi-created server also running on linux, so I'm very
confident it works as described :-)
I have also read your document (pdf):
http://www.freepascal.org/~michael/articles/lazmail/lazmail-en.pdf

But it seems like I still need an example showing how to enable the SSL (port
465) *without* modifying Synapse itself...
This is not mentioned there (also not mentioned are the uses entries for the
example code to work...).

I found this thread in the forum stating that it is written to help for this
problem:
https://forum.lazarus.freepascal.org/index.php?topic=27222.msg168067#msg168067

But the solution here seems to *modify* Synapse package code itself, which I
think is a very bad idea, especially for code that needs to build on "out of the
box" Lazarus installations only specifying which packages to install.

It is very strange to me.
So a working SSL SMTP sending example (with file attachments)would help a lot
because my mail server demands such validation to allow sending.
--
Bo Berglund
Developer in Sweden

_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pa
Michael Van Canneyt via fpc-pascal
2021-05-10 08:08:53 UTC
Permalink
Post by Bo Berglund via fpc-pascal
I have now installed Synapse 40.1 in LKazarus 2.0.12 with Fpc 3.2.0
Post by Michael Van Canneyt via fpc-pascal
I use it myself in a headless FPC-created server running on linux, since many many
years, and use it in a Delphi-created server also running on linux, so I'm very
confident it works as described :-)
http://www.freepascal.org/~michael/articles/lazmail/lazmail-en.pdf
But it seems like I still need an example showing how to enable the SSL (port
465) *without* modifying Synapse itself...
This is not mentioned there (also not mentioned are the uses entries for the
example code to work...).
I found this thread in the forum stating that it is written to help for this
https://forum.lazarus.freepascal.org/index.php?topic=27222.msg168067#msg168067
But the solution here seems to *modify* Synapse package code itself, which I
think is a very bad idea, especially for code that needs to build on "out of the
box" Lazarus installations only specifying which packages to install.
It is very strange to me.
So a working SSL SMTP sending example (with file attachments)would help a lot
because my mail server demands such validation to allow sending.
You don't need to change Synapse ?

My setup is basically:

FSMTP.TargetHost:=MailCfg.HostName;
FSMTP.TargetPort:=IntToStr(MailCfg.Port);
FSMTP.AutoTLS:=MailCfg.UseTLS;
FSMTP.FullSSL:=MailCfg.FullSSL;
FSMTP.Username:=MailCfg.SMTPUserName;
FSMTP.Password:=MailCfg.SMTPPassword;

You need these properties:

{:If is set to true, then upgrade to SSL/TLS mode if remote server support it.}
property AutoTLS: Boolean read FAutoTLS Write FAutoTLS;
{:SSL/TLS mode is used from first contact to server. Servers with full
SSL/TLS mode usualy using non-standard TCP port!}
property FullSSL: Boolean read FFullSSL Write FFullSSL;

That's it. From your story, it seems you just need to set
FSMTP.TargetPort:=465;
FSMTP.FullSSL:=True;

Michael.
_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinf
Bo Berglund via fpc-pascal
2021-05-10 09:18:33 UTC
Permalink
On Mon, 10 May 2021 10:08:53 +0200 (CEST), Michael Van Canneyt via fpc-pascal
Post by Michael Van Canneyt via fpc-pascal
Post by Bo Berglund via fpc-pascal
I have now installed Synapse 40.1 in LKazarus 2.0.12 with Fpc 3.2.0
Post by Michael Van Canneyt via fpc-pascal
I use it myself in a headless FPC-created server running on linux, since many many
years, and use it in a Delphi-created server also running on linux, so I'm very
confident it works as described :-)
http://www.freepascal.org/~michael/articles/lazmail/lazmail-en.pdf
But it seems like I still need an example showing how to enable the SSL (port
465) *without* modifying Synapse itself...
This is not mentioned there (also not mentioned are the uses entries for the
example code to work...).
I found this thread in the forum stating that it is written to help for this
https://forum.lazarus.freepascal.org/index.php?topic=27222.msg168067#msg168067
But the solution here seems to *modify* Synapse package code itself, which I
think is a very bad idea, especially for code that needs to build on "out of the
box" Lazarus installations only specifying which packages to install.
It is very strange to me.
So a working SSL SMTP sending example (with file attachments)would help a lot
because my mail server demands such validation to allow sending.
You don't need to change Synapse ?
FSMTP.TargetHost:=MailCfg.HostName;
FSMTP.TargetPort:=IntToStr(MailCfg.Port);
FSMTP.AutoTLS:=MailCfg.UseTLS;
FSMTP.FullSSL:=MailCfg.FullSSL;
FSMTP.Username:=MailCfg.SMTPUserName;
FSMTP.Password:=MailCfg.SMTPPassword;
{:If is set to true, then upgrade to SSL/TLS mode if remote server support it.}
property AutoTLS: Boolean read FAutoTLS Write FAutoTLS;
{:SSL/TLS mode is used from first contact to server. Servers with full
SSL/TLS mode usualy using non-standard TCP port!}
property FullSSL: Boolean read FFullSSL Write FFullSSL;
That's it. From your story, it seems you just need to set
FSMTP.TargetPort:=465;
FSMTP.FullSSL:=True;
Not so simple when you read scores of Internet pages on the subject...
Maybe I am reading an old version (from 2012) of your document lazmail-en.pdf?
The example I have found for the attachments handling uses a call to SendToRaw
inside Synapse where I cannot get at the SSL handling (without changing the
Synapse package code).

Here is where I am at now trying to make a function to send email with a
plaintext message plus at least one file attachment.
I started with the simple example from the wiki page and next I need to expand
it with code from the pdf regarding the attachments (once tyhe plain text
function works):

(*******************************************************************************
* This function is based on the examples in:
* https://wiki.freepascal.org/Synapse#Sending_email
* and
* https://www.freepascal.org/~michael/articles/lazmail/lazmail-en.pdf
********************************************************************************)
function SendSSLMail(const Subject, MailTo, MailFrom: string; Body, Attachments:
TStrings): boolean;
var
SMTP: TSMTPSend;
begin
SMTP:=TSMTPSend.Create;
try
SMTP.UserName := FSmtpUser;
SMTP.Password := FSmtpPasswd;
SMTP.TargetHost:= FSmtpHost;
SMTP.TargetPort := FSmtpPort; //465
SMTP.AutoTLS := true;
SMTP.FullSSL:=true;

if SMTP.Login then
begin
//What is happening here? 3 SMTP calls in a boolean expression?
Result:=SMTP.MailFrom(MailFrom, Length(Body.Text)) and
SMTP.MailTo(MailTo) and
SMTP.MailData(Body);
SMTP.Logout;
end;

finally
SMTP.Free;
end;
end;

Where is the actual sending of the email happening?
And how do I add the attachments?
--
Bo Berglund
Developer in Sweden

_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.freepascal.org/cgi-
Michael Van Canneyt via fpc-pascal
2021-05-10 09:40:41 UTC
Permalink
Post by Bo Berglund via fpc-pascal
Not so simple when you read scores of Internet pages on the subject...
99% of what is written on internet is junk or outdated.

OK, maybe it's only 98%.

Check the synapse sources, that's all you need.
The handling of attachments is well explained on the synapse homepage/wiki.

http://www.ararat.cz/synapse/doku.php/public:howto
http://www.ararat.cz/synapse/doku.php/public:howto:mimeparts
Post by Bo Berglund via fpc-pascal
Where is the actual sending of the email happening?
And how do I add the attachments?
It is explained in my article. Nothing has changed in this regard.
Didn't you read the section on attachments ?

in the below, aMailData is a record with MailBody, MailHTML strings, and a list of
recipients 'Recipients' and attachment filenames in Attachments.

var
Msg: TMimeMess;
Body,Html : TStringList;
H,PM,P,Rel,Alt : TMimePart;
Recips : TArray<String>;

begin
Msg.Header.From := FSMTP.Username;
Msg.Header.Subject:=aMailData.Subject;
for S in Recips do
Msg.Header.ToList.Add(S);
if (aMailData.MailBody<>'') and (aMailData.MailHTMl<>'') then
begin
PM:=Msg.AddPartMultipart('mixed',Nil);
Rel := Msg.AddPartMultipart('related', P);
Alt := Msg.AddPartMultipart('alternative', Rel);
P:=Alt;
end;
if aMailData.MailBody<>'' then
begin
Body:=TStringList.Create;
Body.Text:=aMailData.MailBody;
Body.WriteBOM:=False;
Msg.AddPartText(Body,P);
end;
if aMailData.MailHTMl<>'' then
begin
HTML:=TStringList.Create;
HTML.WriteBOM:=False;
HTML.Text:=aMailData.MailHTMl;
H:=Msg.AddPartHTML(HTML,P);
H.ConvertCharset:=False;
// H.EncodingCode:=ME_BASE64;
H.EncodePart;
H.EncodePartHeader;
end;
// Todo : attachments
// Add all attachments, assume Attachments is a stringlist with
// filenames
For I:=0 to aMailData.Attachments.Count-1 do
Msg.AddPartBinaryFromFile(Attachments[I],PM);
// Compose message
Msg.EncodeMessage;
if not FSMTP.Login then
Raise EDaemon.CreateFmt(SErrLoginFailed,[Fsmtp.EnhCodeString]);
//If you successfully pass authorization to the remote server
If Not FSMTP.AuthDone Then
Raise EDaemon.CreateFmt(SErrLoginFailed,[Fsmtp.EnhCodeString]);
//Send MAIL FROM SMTP command to set sender’s e-mail address.
If Not FSMTP.MailFrom('***@ourcompany', Length(Msg.Lines.text)) then
Raise EDaemon.CreateFmt(SErrMailFromFailed,[Fsmtp.EnhCodeString]);
For S in aMailData.Recipients do
begin
If Not FSMTP.MailTo(S) Then
Raise EDaemon.CreateFmt(SMailtoFailed,[Fsmtp.EnhCodeString]);
if not FSMTP.MailData(Msg.Lines) Then
Raise EDaemon.CreateFmt(SMailDataFailed,[Fsmtp.EnhCodeString]);
end;

The above is actual code from a program currently in production.
This together with the sample from the article should be plenty to create
your own code.

Michael.
Bo Berglund via fpc-pascal
2021-05-10 11:11:26 UTC
Permalink
On Mon, 10 May 2021 11:40:41 +0200 (CEST), Michael Van Canneyt via fpc-pascal
Post by Michael Van Canneyt via fpc-pascal
Post by Bo Berglund via fpc-pascal
Not so simple when you read scores of Internet pages on the subject...
99% of what is written on internet is junk or outdated.
OK, maybe it's only 98%.
Check the synapse sources, that's all you need.
Yes it really looks like the SendToRaw, SendToEx and SendTo functions at the
bottom are intended as examples...
I wonder if this is the structure elsewhere too...
Post by Michael Van Canneyt via fpc-pascal
The handling of attachments is well explained on the synapse homepage/wiki.
http://www.ararat.cz/synapse/doku.php/public:howto
http://www.ararat.cz/synapse/doku.php/public:howto:mimeparts
Post by Bo Berglund via fpc-pascal
Where is the actual sending of the email happening?
And how do I add the attachments?
It is explained in my article. Nothing has changed in this regard.
Didn't you read the section on attachments ?
Yes I did but it involved calling the SendToRaw function inside Synapse at the
end and therefore hiding the SMTP object where the SSL stuff has to be set...
Post by Michael Van Canneyt via fpc-pascal
in the below, aMailData is a record with MailBody, MailHTML strings, and a list of
recipients 'Recipients' and attachment filenames in Attachments.
var
Msg: TMimeMess;
Body,Html : TStringList;
H,PM,P,Rel,Alt : TMimePart;
Recips : TArray<String>;
begin
Msg.Header.From := FSMTP.Username;
Msg.Header.Subject:=aMailData.Subject;
for S in Recips do
Msg.Header.ToList.Add(S);
if (aMailData.MailBody<>'') and (aMailData.MailHTMl<>'') then
begin
PM:=Msg.AddPartMultipart('mixed',Nil);
Rel := Msg.AddPartMultipart('related', P);
Alt := Msg.AddPartMultipart('alternative', Rel);
P:=Alt;
end;
if aMailData.MailBody<>'' then
begin
Body:=TStringList.Create;
Body.Text:=aMailData.MailBody;
Body.WriteBOM:=False;
Msg.AddPartText(Body,P);
end;
if aMailData.MailHTMl<>'' then
begin
HTML:=TStringList.Create;
HTML.WriteBOM:=False;
HTML.Text:=aMailData.MailHTMl;
H:=Msg.AddPartHTML(HTML,P);
H.ConvertCharset:=False;
// H.EncodingCode:=ME_BASE64;
H.EncodePart;
H.EncodePartHeader;
end;
// Todo : attachments
// Add all attachments, assume Attachments is a stringlist with
// filenames
For I:=0 to aMailData.Attachments.Count-1 do
Msg.AddPartBinaryFromFile(Attachments[I],PM);
// Compose message
Msg.EncodeMessage;
if not FSMTP.Login then
Raise EDaemon.CreateFmt(SErrLoginFailed,[Fsmtp.EnhCodeString]);
//If you successfully pass authorization to the remote server
If Not FSMTP.AuthDone Then
Raise EDaemon.CreateFmt(SErrLoginFailed,[Fsmtp.EnhCodeString]);
//Send MAIL FROM SMTP command to set sender’s e-mail address.
Raise EDaemon.CreateFmt(SErrMailFromFailed,[Fsmtp.EnhCodeString]);
For S in aMailData.Recipients do
begin
If Not FSMTP.MailTo(S) Then
Raise EDaemon.CreateFmt(SMailtoFailed,[Fsmtp.EnhCodeString]);
if not FSMTP.MailData(Msg.Lines) Then
Raise EDaemon.CreateFmt(SMailDataFailed,[Fsmtp.EnhCodeString]);
end;
The above is actual code from a program currently in production.
This together with the sample from the article should be plenty to create
your own code.
Michael.
Thanks! Much obliged!

Seems like FSMTP is a globally available object managed somewhere else...
And that is where the SSL handling is defined too.
So it is set up to send a lot of emails.
In my case the mail sending is done in the end of the life of a task execution
thread so it will not live on further.

Slowly wrapping my head around Synapse, never used it before. I have used Indy
on Delphi since 20 years or so and continued that path on FreePascal/Lazarus.
But it does not handle openssl above 1.0.2.... :(
--
Bo Berglund
Developer in Sweden

_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/list
Bo Berglund via fpc-pascal
2021-05-10 18:16:52 UTC
Permalink
On Mon, 10 May 2021 13:11:26 +0200, Bo Berglund via fpc-pascal
Post by Bo Berglund via fpc-pascal
Slowly wrapping my head around Synapse, never used it before. I have used Indy
on Delphi since 20 years or so and continued that path on FreePascal/Lazarus.
But it does not handle openssl above 1.0.2.... :(
I have now sent test emails successfully both from my Windows 10 PC where I test
the Synapse system and an RPi4 system where I develop the server side code.
(Using the exact same source code just building on Windows vs Linux)

I used the SendToRaw() example function in smtpsend as a template for my scaled
down test function
It somehow found OpenSSL by itself even though I have not supplied any dll:s as
needed with the Indy10 SSL emailing on Windows.
On Linux I expect it used the standard ways to find Openssl and used that.

So I will continue down this path, next thing is to supply an attachment file
too...

Question on Synapse SMTP:
Is there any way Synapse will generate an exception if something goes wrong, or
is the boolean Result the only way to see if something bad happened?
Can one see some error message if it fails?
--
Bo Berglund
Developer in Sweden

_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.fr
Virgo Pärna via fpc-pascal
2021-05-10 09:24:37 UTC
Permalink
Post by Michael Van Canneyt via fpc-pascal
That's it. From your story, it seems you just need to set
FSMTP.TargetPort:=465;
FSMTP.FullSSL:=True;
Also ssl_openssl must be in uses somewhere in program to include
openssl support for Synapse.
--
Virgo Pärna
***@mail.ee

_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.freepascal.org/cgi-bin
Bo Berglund via fpc-pascal
2021-05-11 21:35:55 UTC
Permalink
On Mon, 10 May 2021 09:24:37 -0000 (UTC), Virgo Pärna via fpc-pascal
Post by Virgo Pärna via fpc-pascal
Post by Michael Van Canneyt via fpc-pascal
That's it. From your story, it seems you just need to set
FSMTP.TargetPort:=465;
FSMTP.FullSSL:=True;
Also ssl_openssl must be in uses somewhere in program to include
openssl support for Synapse.
Of course, but as I said the basic mail sending is working I just have a hard
time understanding how to add file attachments.
It would not have worked unless the proper uses are added to the pas file and
also the laz_synapse package set as required for the project.

The only attachment example I have (from Michael) brings in mime, which I don't
understand much of and the synapse docs are very hard reading too.
So right now I try to read up on how to actually handle the mime object here...

And I had an additional question:

Does Synapse throw exceptions when errors happen? It does not look like that in
the code I have examined so far but I have only looked in two units..

That is what Indy does so one must have try-except in order not to get a total
app failure.
--
Bo Berglund
Developer in Sweden

_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/
wkitty42--- via fpc-pascal
2021-05-12 10:16:56 UTC
Permalink
Post by Bo Berglund via fpc-pascal
Of course, but as I said the basic mail sending is working I just have a hard
time understanding how to add file attachments.
It would not have worked unless the proper uses are added to the pas file and
also the laz_synapse package set as required for the project.
The only attachment example I have (from Michael) brings in mime
mime encoding is the modern way of attaching binary files to email messages...
we used to use uu and xx encoding... in all three cases, the bytes of the
attached file are converted into 7 bit bytes for transmission... the internet,
in all its glory still doesn't know how to attach files in their raw binary
format... it would rather make the messages (~1/3rd) larger than to save space
and speed but oh well...

FWIW: my only experience with synapse and file attachments was writing a DOS and
OS/2 tool to extract all the parts of a message into separate files so they
could be weeded out and only the real meat of the message used in further
processing and transmission... i've not done anything with creating messages
with mime in them or having attached files... only ripping them apart into their
individual parts...
--
NOTE: No off-list assistance is given without prior approval.
*Please keep mailing list traffic on the list where it belongs!*
_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pas
Michael Van Canneyt via fpc-pascal
2021-05-12 10:42:14 UTC
Permalink
On Mon, 10 May 2021 09:24:37 -0000 (UTC), Virgo PÀrna via fpc-pascal
Post by Virgo Pärna via fpc-pascal
Post by Michael Van Canneyt via fpc-pascal
That's it. From your story, it seems you just need to set
FSMTP.TargetPort:=465;
FSMTP.FullSSL:=True;
Also ssl_openssl must be in uses somewhere in program to include
openssl support for Synapse.
Of course, but as I said the basic mail sending is working I just have a hard
time understanding how to add file attachments.
It would not have worked unless the proper uses are added to the pas file and
also the laz_synapse package set as required for the project.
That is always so, for every package you use out there.
The only attachment example I have (from Michael) brings in mime, which I don't
understand much of and the synapse docs are very hard reading too.
I guess we have a different understanding of "hard reading", then.
So right now I try to read up on how to actually handle the mime object here...
Does Synapse throw exceptions when errors happen? It does not look like that in
the code I have examined so far but I have only looked in two units..
Yes, it does.

You should always assume exceptions. Maybe synapse itself does not throw
one, but e.g. underlying file IO routines might.

Michael.
Bo Berglund via fpc-pascal
2021-05-13 10:38:43 UTC
Permalink
On Wed, 12 May 2021 12:42:14 +0200 (CEST), Michael Van Canneyt via fpc-pascal
Post by Michael Van Canneyt via fpc-pascal
Post by Bo Berglund via fpc-pascal
The only attachment example I have (from Michael) brings in mime, which I don't
understand much of and the synapse docs are very hard reading too.
I guess we have a different understanding of "hard reading", then.
Post by Bo Berglund via fpc-pascal
So right now I try to read up on how to actually handle the mime object here...
I found more reading and now I am a bit confused again:
When using MIME, why do you need to also set the recipient, sender etc for the
SMTP object when it is already part of the MIME object?
Or does SMTP discard its own properties if a MIME package comes along?
--
Bo Berglund
Developer in Sweden

_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.freepas
Michael Van Canneyt via fpc-pascal
2021-05-13 11:18:02 UTC
Permalink
Post by Bo Berglund via fpc-pascal
On Wed, 12 May 2021 12:42:14 +0200 (CEST), Michael Van Canneyt via fpc-pascal
Post by Michael Van Canneyt via fpc-pascal
Post by Bo Berglund via fpc-pascal
The only attachment example I have (from Michael) brings in mime, which I don't
understand much of and the synapse docs are very hard reading too.
I guess we have a different understanding of "hard reading", then.
Post by Bo Berglund via fpc-pascal
So right now I try to read up on how to actually handle the mime object here...
When using MIME, why do you need to also set the recipient, sender etc for the
SMTP object when it is already part of the MIME object?
Recipient and sender are part of the SMTP protocol.

But they are totally independent from the headers that can appear in the message.
This is how lots of people are caught with phishing.
Post by Bo Berglund via fpc-pascal
Or does SMTP discard its own properties if a MIME package comes along?
No, it does not.

Just set both.

Michael.
_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.freepascal.org/cgi
gebylist via fpc-pascal
2021-05-13 11:16:41 UTC
Permalink
Post by Bo Berglund via fpc-pascal
When using MIME, why do you need to also set the recipient, sender etc for the
SMTP object when it is already part of the MIME object?
Or does SMTP discard its own properties if a MIME package comes along?
Because MIME and SMTP is not same. Synapse's MimePart just get RFC2822
raw plaintext and decompose it into tree object structure representing
MIME parts. And/or compose it back to plaintext. But where you got mail
raw plaintext? SMTP, IMAP4, POP3, database, file,... (you can use it for
HTTP forms too!)

So, SMTP is just one of many options. MIME is independent.

SMTP deliver messages by SMTP envelope, it ignoring message headers.
Look at for any raw message from this conference. You are not written as
recepient in "To" header, however you got it. You have been written as
recepient in SMTP envelope only, not in message text.

Lukas.

_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listin
Bo Berglund via fpc-pascal
2021-05-14 22:25:56 UTC
Permalink
On Wed, 12 May 2021 12:42:14 +0200 (CEST), Michael Van Canneyt via fpc-pascal
Post by Michael Van Canneyt via fpc-pascal
Post by Bo Berglund via fpc-pascal
So right now I try to read up on how to actually handle the mime object here...
Does Synapse throw exceptions when errors happen? It does not look like that in
the code I have examined so far but I have only looked in two units..
Yes, it does.
You should always assume exceptions. Maybe synapse itself does not throw
one, but e.g. underlying file IO routines might.
So I have succeeded in sending a zip file as attachment using Synapse code
snippets from your pdf and also the smtp source examples.

However, when I send to 3 of my email addresses (one To and two Cc addresses) I
get the email only to one of them. It does not matter if I place that address
first or in the middle of the address list, it will get the email in any case.

But the two other accounts (my company email managed by Google and my private
Gmail) do not get the messages.

Apart from reordering the 3 mail addresses I have also tried to replace the
attached zipfile with another non-zip binary file, and then the emails to Gmail
accounts are received.

This is baffling and makes it hard to move on. Our monitoring system packages
measured data into a zipfile in order for it to be reduced in size and because
the data set consists of several files which need to be together.

Is there some kind of blocking for emails with zip attachments which stops them
from being delivered to GMail accounts?

If so, is there some other type of compressed format I can use which is allowed
by GMail?
--
Bo Berglund
Developer in Sweden

_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.freepascal.org/cgi-bi
Tomas Hajny via fpc-pascal
2021-05-14 23:11:07 UTC
Permalink
Post by Bo Berglund via fpc-pascal
On Wed, 12 May 2021 12:42:14 +0200 (CEST), Michael Van Canneyt via fpc-pascal
Post by Michael Van Canneyt via fpc-pascal
Post by Bo Berglund via fpc-pascal
So right now I try to read up on how to actually handle the mime object here...
Does Synapse throw exceptions when errors happen? It does not look like that in
the code I have examined so far but I have only looked in two units..
Yes, it does.
You should always assume exceptions. Maybe synapse itself does not throw
one, but e.g. underlying file IO routines might.
So I have succeeded in sending a zip file as attachment using Synapse code
snippets from your pdf and also the smtp source examples.
However, when I send to 3 of my email addresses (one To and two Cc addresses) I
get the email only to one of them. It does not matter if I place that address
first or in the middle of the address list, it will get the email in any case.
But the two other accounts (my company email managed by Google and my private
Gmail) do not get the messages.
Apart from reordering the 3 mail addresses I have also tried to replace the
attached zipfile with another non-zip binary file, and then the emails to Gmail
accounts are received.
This is baffling and makes it hard to move on. Our monitoring system packages
measured data into a zipfile in order for it to be reduced in size and because
the data set consists of several files which need to be together.
Is there some kind of blocking for emails with zip attachments which stops them
from being delivered to GMail accounts?
If so, is there some other type of compressed format I can use which is allowed
by GMail?
Probably a silly question, but have you checked the Spam folder in
GMail? In general, you can certainly send ZIP files to GMail. Also, what
was the size of those attachments? The e-mail used as sender address
didn't get any SMTP error message, did it? Personally, I'd guess for
some other difference in your sending apart from the attachment type.

Tomas
_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listi
Bo Berglund via fpc-pascal
2021-05-15 06:52:00 UTC
Permalink
On Sat, 15 May 2021 01:11:07 +0200, Tomas Hajny via fpc-pascal
Post by Tomas Hajny via fpc-pascal
Post by Bo Berglund via fpc-pascal
Is there some kind of blocking for emails with zip attachments which stops them
from being delivered to GMail accounts?
If so, is there some other type of compressed format I can use which is allowed
by GMail?
Probably a silly question, but have you checked the Spam folder in
GMail? In general, you can certainly send ZIP files to GMail. Also, what
was the size of those attachments? The e-mail used as sender address
didn't get any SMTP error message, did it? Personally, I'd guess for
some other difference in your sending apart from the attachment type.
It is not a size problem, the test mail contains just a very small zipfile
sample (5 kb in size).
And the mail is not in the spam folder either, it is simply silently rejected by
GMail... No error message.

It turns out that GMail inspects the *content* of the zipfile and if it
discovers "dangerous" constituent files it blocks delivery altogether.
https://support.google.com/mail/answer/6590?hl=en#zippy=%2Cmessages-that-have-attachments%2Cmessages-that-dont-have-attachments

In my case there is a small text file inside named <something>.cmd which is NOT
a Windows command file (similar to a batch file) but a file with a set of
equipment commands and geometry information....

So I tested by changing the extension from .cmd to ,cmd.txt and then delivery
started working...
So now I have to modify the automatic server so it will rename this particular
file using a different extension.
But that is easier than dealing with the OpenSSL incompatibility of Indy10 in
any case.
--
Bo Berglund
Developer in Sweden

_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-
Michael Van Canneyt via fpc-pascal
2021-05-15 07:00:08 UTC
Permalink
Post by Bo Berglund via fpc-pascal
It is not a size problem, the test mail contains just a very small zipfile
sample (5 kb in size).
And the mail is not in the spam folder either, it is simply silently rejected by
GMail... No error message.
It turns out that GMail inspects the *content* of the zipfile and if it
discovers "dangerous" constituent files it blocks delivery altogether.
https://support.google.com/mail/answer/6590?hl=en#zippy=%2Cmessages-that-have-attachments%2Cmessages-that-dont-have-attachments
In my case there is a small text file inside named <something>.cmd which is NOT
a Windows command file (similar to a batch file) but a file with a set of
equipment commands and geometry information....
So I tested by changing the extension from .cmd to ,cmd.txt and then delivery
started working...
So now I have to modify the automatic server so it will rename this particular
file using a different extension.
But that is easier than dealing with the OpenSSL incompatibility of Indy10 in
any case.
Glad you got it working.

I worked for some time for a mass mailing company.
From that experience I assure you that delivering mail is NOT easy.

Meanwhile, there are a lot of safety mechanisms installed on all "big" mail
platforms, and getting a mail delivered becomes more and more difficult.

Michael.
_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo
Bo Berglund via fpc-pascal
2021-05-15 16:02:04 UTC
Permalink
On Sat, 15 May 2021 09:00:08 +0200 (CEST), Michael Van Canneyt via fpc-pascal
Post by Michael Van Canneyt via fpc-pascal
Glad you got it working.
I worked for some time for a mass mailing company.
From that experience I assure you that delivering mail is NOT easy.
Meanwhile, there are a lot of safety mechanisms installed on all "big" mail
platforms, and getting a mail delivered becomes more and more difficult.
Well, after a few more tests two of my test recipients again did not receive the
emails. Both are handled by GMail (of course). Now the reason is that GMail
determined that the recipient had gotten too many "similar" emails so it stopped
accepting them.
And I also saw that it is getting suspicious of the "non-validated" sender...

All of this is a PITA since I am working on porting an automatic environment
monitoring system from Delphi to FreePascal and Linux. Here the results will be
emailed packaged in a zipfile several times a day to a few recipients and it is
not acceptable that the recipient's mail server blocks these emails.

The body of the message is fixed at the moment, I could add a timestamp string
to it but not much more to make it "new" every time.
... :(
--
Bo Berglund
Developer in Sweden

_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.freepasc
Michael Van Canneyt via fpc-pascal
2021-05-15 16:11:22 UTC
Permalink
Post by Bo Berglund via fpc-pascal
On Sat, 15 May 2021 09:00:08 +0200 (CEST), Michael Van Canneyt via fpc-pascal
Post by Michael Van Canneyt via fpc-pascal
Glad you got it working.
I worked for some time for a mass mailing company.
From that experience I assure you that delivering mail is NOT easy.
Meanwhile, there are a lot of safety mechanisms installed on all "big" mail
platforms, and getting a mail delivered becomes more and more difficult.
Well, after a few more tests two of my test recipients again did not receive the
emails. Both are handled by GMail (of course). Now the reason is that GMail
determined that the recipient had gotten too many "similar" emails so it stopped
accepting them.
And I also saw that it is getting suspicious of the "non-validated" sender...
All of this is a PITA since I am working on porting an automatic environment
monitoring system from Delphi to FreePascal and Linux. Here the results will be
emailed packaged in a zipfile several times a day to a few recipients and it is
not acceptable that the recipient's mail server blocks these emails.
Welcome to the world of mailing.
I wish I could say it gets better, but it does not.
Post by Bo Berglund via fpc-pascal
The body of the message is fixed at the moment, I could add a timestamp string
to it but not much more to make it "new" every time.
... :(
It might be better not to mail this, but to upload results to a server using
http, which puts everything in a database, and make a small frontend for your database.

Michael.
_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/m
Bo Berglund via fpc-pascal
2021-05-15 17:12:00 UTC
Permalink
On Sat, 15 May 2021 18:11:22 +0200 (CEST), Michael Van Canneyt via fpc-pascal
Post by Michael Van Canneyt via fpc-pascal
Welcome to the world of mailing.
I wish I could say it gets better, but it does not.
Post by Bo Berglund via fpc-pascal
The body of the message is fixed at the moment, I could add a timestamp string
to it but not much more to make it "new" every time.
... :(
It might be better not to mail this, but to upload results to a server using
http, which puts everything in a database, and make a small frontend for your database.
Well, then we would have to supply a website too...
--
Bo Berglund
Developer in Sweden

_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.fr
Bo Berglund via fpc-pascal
2021-05-17 20:06:10 UTC
Permalink
On Sat, 15 May 2021 09:00:08 +0200 (CEST), Michael Van Canneyt via fpc-pascal
Post by Michael Van Canneyt via fpc-pascal
Glad you got it working.
I worked for some time for a mass mailing company.
From that experience I assure you that delivering mail is NOT easy.
Meanwhile, there are a lot of safety mechanisms installed on all "big" mail
platforms, and getting a mail delivered becomes more and more difficult.
Michael.
Well, now I got stuck again...
I did all of my code testing on Windows because that is my normal environment.

When all was done I had created a mailsupport unit encapsulating the stuff I
need for my emailings and I used that in a command line mailer to verify that
everything worked OK.
Which it did on Windows except for some fussy mailservers who would not receive
the emails (my GMail account), but the email was in any case sent.

But then when I moved to Linux (on Raspberry Pi3) I always got errors on mail
send. So no outgoing email.

So I have now finally traced the execution using the Lazarus debugger and it
seems like Synapse does not connect using SSL after all.. :(

I have set it up as well as I have understood the documentation with the smtp
switches for SSL and TLS active (set to true) and the port and user is set as on
Windows (after all I copied the source files over to the Linux box and opened
the project in Lazarus over there). The test emailer has all of the logon etc
info built into the executable (just for testing of course) but failed.

So when I single-step in the code I reach the following location after starting
on SMTP.Connect:

function TSMTPSend.Connect: Boolean;
begin
FSock.CloseSocket;
FSock.Bind(FIPInterface, cAnyPort);
if FSock.LastError = 0 then
FSock.Connect(FTargetHost, FTargetPort);
if FSock.LastError = 0 then
if FFullSSL then
FSock.SSLDoConnect; //<= I get to here
Result := FSock.LastError = 0;
end;

procedure TTCPBlockSocket.SSLDoConnect;
begin
ResetLastError;
if not FSSL.Connect then //<=This goes to no action....
FLastError := WSASYSNOTREADY;
ExceptCheck;
end;

function TCustomSSL.Connect: boolean; //<= To here!
begin
ReturnError;
Result := False;
end;


Then I traced over into the ExceptCheck function:

procedure TBlockSocket.ExceptCheck;
var
e: ESynapseError;
begin
FLastErrorDesc := GetErrorDescEx; // <== HERE
if (LastError <> 0) and (LastError <> WSAEINPROGRESS)
and (LastError <> WSAEWOULDBLOCK) then
begin
DoStatus(HR_Error, IntToStr(FLastError) + ',' + FLastErrorDesc);
if FRaiseExcept then
begin
e := ESynapseError.Create(Format('Synapse TCP/IP Socket error %d: %s',
[FLastError, FLastErrorDesc]));
e.ErrorCode := FLastError;
e.ErrorMessage := FLastErrorDesc;
raise e;
end;
end;
end;

FLastErrorDesc gets set to "SSL/TLS support is not compiled"

So now I do not know what to do, is this indicating that I need to change some
Synapse config to get it working or is it a platform problem (Linux)???

What could I do in order to make SSL/TLS support "compiled"
In the documentation
http://www.ararat.cz/synapse/doku.php/public:howto:sslplugin

they write:
First you must explicitly select what plugin you wish to use. You can do it
simply by adding unit with SSL plugin to your project sources. You can add only
one from SSL plugins in one project! When you wish to use OpenSSL, then add
/ssl_openssl/ to your project uses, for example.

And that is what I have done, it is listed in uses of my mailsupport source file
as:
uses
Classes,
SysUtils,
smtpsend,
ssl_openssl, //<= Here
synautil,
mimemess,
mimepart;

Yet it is "not compiled"...

Very confusing.
--
Bo Berglund
Developer in Sweden

_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listi
gebylist via fpc-pascal
2021-05-17 21:20:16 UTC
Permalink
Post by Bo Berglund via fpc-pascal
And that is what I have done, it is listed in uses of my mailsupport source file
uses
Classes,
SysUtils,
smtpsend,
ssl_openssl, //<= Here
synautil,
mimemess,
mimepart;
Yet it is "not compiled"...
Very confusing.
It is because loading of ssl_openssl plugin failed. Have you installed
OpenSSL libraries on your RPi?

Check function |InitSSLinterface in ssl_openssl_lib unit. I personally
never test ssl_openssl on RPi, maybe some error is here.|

|Lukas.
|
Bo Berglund via fpc-pascal
2021-05-17 22:20:40 UTC
Permalink
On Mon, 17 May 2021 23:20:16 +0200, gebylist via fpc-pascal
Post by gebylist via fpc-pascal
Post by Bo Berglund via fpc-pascal
And that is what I have done, it is listed in uses of my mailsupport source file
uses
Classes,
SysUtils,
smtpsend,
ssl_openssl, //<= Here
synautil,
mimemess,
mimepart;
Yet it is "not compiled"...
Very confusing.
It is because loading of ssl_openssl plugin failed. Have you installed
OpenSSL libraries on your RPi?
How is that done?
Is not openssl part of the Debian and derivatives Linux distros?

Well, I Googled and found a suggested remedy:
sudo apt install libssl-dev

After this was done I ran the exact same code in Lazarus debugger and this time
it got through and the emails were delivered!
Post by gebylist via fpc-pascal
Check function |InitSSLinterface in ssl_openssl_lib unit. I personally
never test ssl_openssl on RPi, maybe some error is here.|
Follow-on question:
Do I have to install dev packages like this on the target system as well (one
where the application is not going to be built on?

Or is it only needed to be on the *development* system?
--
Bo Berglund
Developer in Sweden

_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mail
Michael Van Canneyt via fpc-pascal
2021-05-17 22:25:51 UTC
Permalink
Post by Bo Berglund via fpc-pascal
On Mon, 17 May 2021 23:20:16 +0200, gebylist via fpc-pascal
Post by gebylist via fpc-pascal
Post by Bo Berglund via fpc-pascal
And that is what I have done, it is listed in uses of my mailsupport source file
uses
Classes,
SysUtils,
smtpsend,
ssl_openssl, //<= Here
synautil,
mimemess,
mimepart;
Yet it is "not compiled"...
Very confusing.
It is because loading of ssl_openssl plugin failed. Have you installed
OpenSSL libraries on your RPi?
How is that done?
Is not openssl part of the Debian and derivatives Linux distros?
sudo apt install libssl-dev
After this was done I ran the exact same code in Lazarus debugger and this time
it got through and the emails were delivered!
Post by gebylist via fpc-pascal
Check function |InitSSLinterface in ssl_openssl_lib unit. I personally
never test ssl_openssl on RPi, maybe some error is here.|
Do I have to install dev packages like this on the target system as well (one
where the application is not going to be built on?
Or is it only needed to be on the *development* system?
It is always needed.

Basically, this package installs a symlink from libssl.so to libssl.so.x.y.z;
you can make this symlink yourself if you prefer.

Michael.
_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.freepascal.org/cg
Bo Berglund via fpc-pascal
2021-05-18 07:59:57 UTC
Permalink
On Tue, 18 May 2021 00:25:51 +0200 (CEST), Michael Van Canneyt via fpc-pascal
Post by Michael Van Canneyt via fpc-pascal
Post by Bo Berglund via fpc-pascal
Do I have to install dev packages like this on the target system as well (one
where the application is not going to be built on?
Or is it only needed to be on the *development* system?
It is always needed.
Basically, this package installs a symlink from libssl.so to libssl.so.x.y.z;
you can make this symlink yourself if you prefer.
So if I don't install the dev stuff the libssl.so is not present but the
libssl.so.1.1 is.


I tried find it below /usr:

$ find /usr/ -name libssl*
/usr/lib/arm-linux-gnueabihf/libssl.a
/usr/lib/arm-linux-gnueabihf/libssl.so #<== here!
/usr/lib/arm-linux-gnueabihf/libssl.so.1.1 #<== here!
/usr/lib/arm-linux-gnueabihf/pkgconfig/libssl.pc
/usr/lib/arm-linux-gnueabihf/libssl3.so
/usr/share/doc/libssl1.1
/usr/share/doc/libssl-dev

And then:

$ ll /usr/lib/arm-linux-gnueabihf/libssl.so
lrwxrwxrwx 1 root root 13 2021-03-25 11:22
/usr/lib/arm-linux-gnueabihf/libssl.so -> libssl.so.1.1 #<== here!

I have now checked that this link is not present on an RPi3 where the dev
package is not installed. So I guess I have to make a note about this too.
--
Bo Berglund
Developer in Sweden

_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.freepascal.org/
Travis Siegel via fpc-pascal
2021-05-17 23:42:57 UTC
Permalink
The -dev part of the package is necessary for the headers used for
compiling, any target system running the finished product will not
require the -dev version of the packages to be installed, since they
won't be using the header files directly.
Post by Bo Berglund via fpc-pascal
On Mon, 17 May 2021 23:20:16 +0200, gebylist via fpc-pascal
Post by gebylist via fpc-pascal
Post by Bo Berglund via fpc-pascal
And that is what I have done, it is listed in uses of my mailsupport source file
uses
Classes,
SysUtils,
smtpsend,
ssl_openssl, //<= Here
synautil,
mimemess,
mimepart;
Yet it is "not compiled"...
Very confusing.
It is because loading of ssl_openssl plugin failed. Have you installed
OpenSSL libraries on your RPi?
How is that done?
Is not openssl part of the Debian and derivatives Linux distros?
sudo apt install libssl-dev
After this was done I ran the exact same code in Lazarus debugger and this time
it got through and the emails were delivered!
Post by gebylist via fpc-pascal
Check function |InitSSLinterface in ssl_openssl_lib unit. I personally
never test ssl_openssl on RPi, maybe some error is here.|
Do I have to install dev packages like this on the target system as well (one
where the application is not going to be built on?
Or is it only needed to be on the *development* system?
_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc
Michael Van Canneyt via fpc-pascal
2021-05-18 06:07:30 UTC
Permalink
Post by Travis Siegel via fpc-pascal
The -dev part of the package is necessary for the headers used for
compiling, any target system running the finished product will not
require the -dev version of the packages to be installed, since they
won't be using the header files directly.
This is not correct for synapse. The name of the library that synapse loads
(it loads dynamically) is the dev name (.so), without version number.

Michael.
_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listi
Jean SUZINEAU via fpc-pascal
2021-05-12 12:25:30 UTC
Permalink
I do not guarantee anything, I didn't use this recently, but I have a
function for sending mail with attachments using Synapse.

It's the function MailTo_SMTP in this unit :
https://github.com/jsuzineau/pascal_o_r_mapping/blob/master/pascal_o_r_mapping/3_Data/uMailTo.pas
(my code is under LGPL, you can extract and reuse freely)

Normally the version of Synapse used in this code is here :
https://github.com/jsuzineau/pascal_o_r_mapping/tree/master/pascal_o_r_mapping/7_sources_externes/synapse
Jean SUZINEAU via fpc-pascal
2021-05-12 12:39:38 UTC
Permalink
My code uses others units from this directories:
https://github.com/jsuzineau/pascal_o_r_mapping/tree/master/pascal_o_r_mapping/2_Units
https://github.com/jsuzineau/pascal_o_r_mapping/tree/master/pascal_o_r_mapping/3_Data
Particularly, Formate_Liste from
https://github.com/jsuzineau/pascal_o_r_mapping/blob/master/pascal_o_r_mapping/2_Units/uuStrings.pas
_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinf
Arne Hanssen via fpc-pascal
2021-05-06 12:56:14 UTC
Permalink
Post by Bo Berglund via fpc-pascal
[..]
I may even use some external program for mailing by using TProcess to run it....
But what? THere used to be something called sendmail or similar in Linux but
right now I cannot see it on my boxes. And I am uncertain if it can do SSL
logins and accept attachment files.
There is 'msmtp':

https://marlam.de/msmtp/

If everything else fails...?
Post by Bo Berglund via fpc-pascal
[..]
--
Best regards
Arne Hanssen

_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://l
Travis Siegel via fpc-pascal
2021-05-06 13:07:26 UTC
Permalink
Post by Bo Berglund via fpc-pascal
Post by Michael Van Canneyt via fpc-pascal
Post by Bo Berglund via fpc-pascal
Post by Nico Neumann via fpc-pascal
Indy has support for OpenSSL 1.1.1, just not officially (yet).
See https://github.com/IndySockets/Indy/pull/299
THe SMTP server I use requires SSL on port 465.
I have only ever used Indy for things like this.
Use package laz_synapse (in online package manager), unit smtpsend.
I'm using it in FPC and Delphi even today.
In general, it works a lot easier/simpler than Indy.
Unless you need some weird/outdated protocols,
I highly recommend Synapse over Indy.
So only if the emailing synapse is guaranteed GUI-free can I use it.
I may even use some external program for mailing by using TProcess to run it....
But what? THere used to be something called sendmail or similar in Linux but
right now I cannot see it on my boxes. And I am uncertain if it can do SSL
logins and accept attachment files.
For some reason, sendmail has fallen out of favor, (likely because of
it's conceived difficult setup), and most linux distros now use postfix,
which in my opinion isn't any easier to configure, but it does allow for
a wider range of options.

If you check your linux boxes, you'll probably see postfix as the mta,
and it can indeed be called to transfer mail from programs. I don't have
any examples of this, but the documentation says it can be done.  I
don't know if there's another program application programmers use, but
with some digging, you should be able to get it to work.

_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.freepascal.org/c
Dennis Lee Bieber via fpc-pascal
2021-05-30 17:36:08 UTC
Permalink
On Thu, 06 May 2021 13:54:14 +0200, Bo Berglund via fpc-pascal
<fpc-***@lists.freepascal.org> declaimed
the following:

Okay, slipping in late and you may have solved your problem by now
but...
Post by Bo Berglund via fpc-pascal
I may even use some external program for mailing by using TProcess to run it....
But what? THere used to be something called sendmail or similar in Linux but
right now I cannot see it on my boxes. And I am uncertain if it can do SSL
logins and accept attachment files.
... an "apt search smtp" on a Debian Buster install finds...

esmtp/stable 1.2-17 amd64
user configurable relay-only MTA

esmtp-run/stable,stable 1.2-17 all
user configurable relay-only MTA - the regular MTA

exim4-daemon-heavy/stable 4.92-8+deb10u6 amd64
Exim MTA (v4) daemon with extended features, including exiscan-acl

exim4-doc-html/stable,stable 4.92-1 all
documentation for the Exim MTA (v4) in html format

exim4-doc-info/stable,stable 4.92-1 all
documentation for the Exim MTA (v4) in info format

...
msmtp/stable 1.8.3-1 amd64
light SMTP client with support for server profiles

msmtp-gnome/stable 1.8.3-1 amd64
light SMTP client with support for server profiles - with GNOME keyring
support

msmtp-mta/stable 1.8.3-1 amd64
light SMTP client with support for server profiles - the regular MTA


opensmtpd/stable,stable 6.0.3p1-5+deb10u4 amd64
secure, reliable, lean, and easy-to configure SMTP server

opensmtpd-extras/stable 5.7.1-4+b2 amd64
addons for the OpenSMTPD SMTP server

...
sendemail/stable,stable 1.56-5 all
lightweight, command line SMTP email client

sendmail/stable,stable,now 8.15.2-14~deb10u1 all [installed,automatic]
powerful, efficient, and scalable Mail Transport Agent (metapackage)

sendmail-bin/stable,now 8.15.2-14~deb10u1 amd64 [installed,automatic]
powerful, efficient, and scalable Mail Transport Agent

{I'm surprised it installed old fat sendmail, and not something slimmer...}

For your use, a "relay-only" daemon might be recommended. {esmtp}
--
Wulfraed Dennis Lee Bieber AF6VN
***@ix.netcom.com http://wlfraed.microdiversity.freeddns.org/

_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo
Bo Berglund via fpc-pascal
2021-06-05 20:04:43 UTC
Permalink
On Sun, 30 May 2021 13:36:08 -0400, Dennis Lee Bieber via fpc-pascal
Post by Dennis Lee Bieber via fpc-pascal
Okay, slipping in late and you may have solved your problem by now
but...
Yes, I ditched Indy10 for smtp emailing and instead used Synapse 40.1 from the
OnLinePackageManager in Lazarus.
Took a while to understand how it worked but then I could finish the report
emailing part of the application.
--
Bo Berglund
Developer in Sweden

_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.
gebylist via fpc-pascal
2021-06-06 06:58:21 UTC
Permalink
Post by Bo Berglund via fpc-pascal
Yes, I ditched Indy10 for smtp emailing and instead used Synapse 40.1
from the OnLinePackageManager in Lazarus.
I am not sure what is mean by "Synapse 40.1" and how
OnlinePackageManager working, because Synapse itself leave this
numbering before years and most recent version of Synapse is available
on SVN only. And this most recent version have new SSL plugin called
ssl_openssl11 with support for OpenSSL 1.1.1.

Remark: Synapse is not component and not need to be installed by
OnlinePakageManager/GetIt in Lazarus/Delphi. Just place Synapse's
sources somewhere, where your project "see it".


Lukas

_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.
Bo Berglund via fpc-pascal
2021-06-06 12:47:27 UTC
Permalink
On Sun, 6 Jun 2021 08:58:21 +0200, gebylist via fpc-pascal
Post by gebylist via fpc-pascal
Post by Bo Berglund via fpc-pascal
Yes, I ditched Indy10 for smtp emailing and instead used Synapse 40.1
from the OnLinePackageManager in Lazarus.
I am not sure what is mean by "Synapse 40.1" and how
This is a package containing networking objects
Post by gebylist via fpc-pascal
OnlinePackageManager working, because Synapse itself leave this
I use Lazarus as my dev IDE and in Lazarus menu:
Package/OnLinePackageManager you can select from a number of available packages
that are not installed by default. Here you will find Synapse 40.1, which is
what I referred to.
Post by gebylist via fpc-pascal
numbering before years and most recent version of Synapse is available
on SVN only. And this most recent version have new SSL plugin called
ssl_openssl11 with support for OpenSSL 1.1.1.
The OLPM version has SSL support that works well in Linux. I don't care much for
Windows where I suppose you need to get some dll files too. In Linux openssl is
nearly always available and works without any extra coding.
Post by gebylist via fpc-pascal
Remark: Synapse is not component and not need to be installed by
OnlinePakageManager/GetIt in Lazarus/Delphi. Just place Synapse's
sources somewhere, where your project "see it".
As I stated it is not installed by default (as a package) but available in a
very simple way through OnLine PackageManager.
OLPM can "install" any package and if it has GUI components it will also compile
that into Lazarus. Not needed for Synapse.
--
Bo Berglund
Developer in Sweden

_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.freepascal.org/cgi-bin
Luca Olivetti via fpc-pascal
2021-06-06 21:14:06 UTC
Permalink
Post by gebylist via fpc-pascal
Just place Synapse's
sources somewhere, where your project "see it".
That's what a lazarus' package does.

Bye
--
Luca
_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/
Loading...