Jump to content
GillesL.

TSslSmtpCli in Console App

Recommended Posts

I am having a problem using TSslSmtpCli (v8.55) in a console app (cgi) under windows 10 and Delphi Tokyo (10.2.3). The problem is I can not assign a procedure (created as a TSmtpRequestDone) to the event OnRequestDone since procedures and methods are not compatible. Using a Form provides a mechanism to do so but creates another problem since the app is a console app and I end up with a run time error 216 as the app terminates. Is there any other way other than creating a new component using TCustomSslSmtpCli as a base.

Share this post


Link to post

Your console application will need events so you can not really take any short cuts.  

 

There is a sample Samples\delphi\MailNewsDemos\OverbyteIcsConSmtp.dpr that should help.

 

Angus

 

 

Share this post


Link to post

I followed the example and used the TSslSmtpCli component instead and it works fine. Thanks for the input.

Share this post


Link to post

You could also try using TIcsMailQueue which sends mail in the same way as TSslSmtpCli but runs a mail queue with repeated retries to multiple servers on failure. Your application would need to keep running until the queue was empty, and not run multiple copies, but mail is more likely to be delivered.

 

Angus

 

Share this post


Link to post

Angus, this model is not suitable for CGI. A CGI module is expected to run as quickly as possible. If a queue and retries have to be done, it must be launched independently by the CGI so that it becomes an independent process. Or the CGI could call a service doing the actual send. Or other similar solutions.

 

Share this post


Link to post

Perhaps FastCGI instead, which runs continually.  I'm just updating the Jose stuff to handle the server side of Json Web Signing/Tokens for REST servers, currently it only does JWS/JWT for REST clients, and was thinking about how it could be used with web servers other than ICS, FastCGI seems a possibility.

 

TIcsMailQueue can be used separately to queue and send email, the queue format is standard SMTP pick-up as used by Microsoft, although I've not used it like that. 

 

 

Angus

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×