Can't send email using ICS (THtmlSmtpCli) from stream in Delphi
We used the ICS , THtmlSmtpCli
to send letters of our applications for some time, both in the flow Main VCL, and the Threads, Earlier this week, we have found that we can no longer send e-mail from Threads. Sending it from the main VCL thread works great.
So I ask the question two times:
- Has anyone experienced the same problem?
- Are there any other components that we could look at for sending emails from Delphi applications.
The code used looks like this:
FRunning := True;
FHtmlSmtpClient := THtmlSmtpCli.Create(nil);
with FHtmlSmtpClient do
begin
Port := '25';
Host := FHost;
AuthType := smtpAuthNone;
ConfirmReceipt := FReadReceipt;
HdrPriority := smtpPriorityNone;
ContentType := smtpHtml;
FromName := FFromAddr;
HdrFrom := FFromAddr;
HdrTo := FToAddr;
HdrSubject := FSubject;
OnCommand := FHtmlSmtpClientCommand;
OnRequestDone := FHtmlSmtpClientRequestDone;
OnSessionClosed := FHtmlSmtpClientSessionClosed;
{ Start first operation to do to send an email }
{ Next operations are started from OnRequestDone event }
Connect;
end;
//Process the requests to send the email
procedure FHtmlSmtpClientRequestDone(Sender: TObject; RqType: TSmtpRequest; ErrorCode: word);
begin
if not FRunning then
Exit;
{ Start next operation, but first check if previous one was OK }
if ErrorCode <> 0 then
begin
FRunning := FALSE; { Terminate All-In-One demo }
Exit;
end;
case RqType of
smtpConnect:
begin
if FHtmlSmtpClient.AuthType = smtpAuthNone then
FHtmlSmtpClient.Helo
else
FHtmlSmtpClient.Ehlo;
end;
smtpHelo: FHtmlSmtpClient.MailFrom;
smtpEhlo: FHtmlSmtpClient.Auth;
smtpAuth: FHtmlSmtpClient.MailFrom;
smtpMailFrom: FHtmlSmtpClient.RcptTo;
smtpRcptTo: FHtmlSmtpClient.Data;
smtpData: FHtmlSmtpClient.Quit;
smtpQuit: FRunning := FALSE;
end;
end;
Regards, Peter.
+3
source to share