[Lazarus] Email sending program using Indy stopped working - seems to be an SSL problem
Bo Berglund
bo.berglund at gmail.com
Sun Jan 14 12:20:55 CET 2024
On Sat, 13 Jan 2024 17:03:55 +0100 (CET), Michael Van Canneyt via lazarus
<lazarus at lists.lazarus-ide.org> wrote:
>You could also use Synapse. I always prefer synapse over Indy.
>
So I have now verified that I cannot use Indy10 for email sending anymore :( ...
I have used Indy since a very long time like 20 years or so when dealing with
Internet accesses. So I am not used to other ways.
Now I have looked around for valid examples which will work like my send
function but using Synapse but the result is confusing.
I have found your pdf document "Sending mails using Lazarus.pdf".
But I am not clear as to how to map the Indy properties to Synapse...
And the example's uses clause is not shown so I don't know what to put there...
In fact I have looked for Synapse and in OnLine Package Manager I find
Synapse_40.1, which I have installed via OLPM. But when looking through the
packages in Lazarus I cannot find any match to synapse at all.
What have I done wrong?
Inside the pdf I found a link to http://synapse.ararat.cz/ but there seems to be
only files from more than 10 years ago, how could they solve the recently
encountered ssl problem?
Could you (or someone else reading this) suggest a new SendSvnMessage function
that will replace the following (snippets) but using Synapse (and say from where
I can get synapse):
uses
...
IdSMTP,
IdMessage,
IdEMailAddress,
IdIOHandler,
IdIOHandlerStack,
IdSSL,
IdSSLOpenSSL,
IdExplicitTLSClientServerBase,
IdMessageBuilder,
...
type
{ TSvnUser } //Data from SVN user config is put here
TSvnUser = class
public
LoginName,
FullName,
Email: string;
end;
{ TSvnMessage }
TSvnMessage = class
private
FSMTP: TIdSMTP;
FSSLHandler: TIdSSLIOHandlerSocketOpenSSL;
FMailMessage: TIdMessage;
FMailServer: string;
FMailLogin: string;
FMailPwd: string;
FMailPort: word;
FMailUseSSL: boolean;
FMailTimeout: integer;
FSvnUsers: TSvnUsers; //A list of users (TSvnUser) and data
...
function TSvnMessage.SendSvnMessage: boolean;
var
sSubject: string;
i: integer;
begin
Result := false;
try
PrepareMessage;
//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;
//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;
procedure TSvnMessage.PrepareMessage;
var
i: integer;
Usr,
Msg: string;
SU: TSvnUser;
MA: TIdEMailAddressItem; //<== Does Synapse have something like this?
begin
(*if Pos('<html>', FMailMessage.Body.Text) > 0 then
FMailMessage.ContentType := 'text/html; charset=utf-8'
else
FMailMessage.ContentType := 'text/plain; charset=utf-8';*)
Msg := 'Recipients:';
for i := 0 to FSubscription.Count - 1 do
begin
Usr := Lowercase(FSubscription[i]);
if Pos('#', Usr) > 0 then Continue;
SU := FSvnUsers.UserByLogin[Usr];
if SU <> NIL then
begin
MA := FMailMessage.Recipients.Add; // How is this done in Synapse?
MA.Name := SU.FullName; // <== The name: 'John Doe'
MA.Address := SU.Email; // <== The address: john.doe at somedomain.com
Msg := Msg + ' ' + Usr;
end;
end;
Log(Msg);
end;
--
Bo Berglund
Developer in Sweden
More information about the lazarus
mailing list