Board index » delphi » SMTP connect in thread{*word*154}

SMTP connect in thread{*word*154}

I have a mailing system that sends mail to clients for order status
purposes.  Sometimes these thread get up to 50 at a time, problem is
sometimes the threads just hang while trying to connect.  The code is in a
tthread object in which

Main process creates thread,
SMTP object is created
Message object is created
DNS object is created.
DNS resolves mail server for client
DNS is freed
SMTP server connects to mail server
SMTP sends mail

But alot of the time, SMTP just hangs on connecting and never comes back,
causing the thread to hang. anyone know of a way to force the smtp to
disconnect?  Sometimes SMTP never recieves a rsponse and the thread just
hangs.

Thanks

 

Re:SMTP connect in thread{*word*154}


Quote

> But alot of the time, SMTP just hangs on connecting and never comes
back,
> causing the thread to hang. anyone know of a way to force the smtp
to
> disconnect?  Sometimes SMTP never recieves a rsponse and the thread
just
> hangs.

Well, if you can drill down your SMTP component heirarchy, you should
be able to get at the socket somewhere.  If you call
closeSocket(socket) from your main thread, or some other 'monitor'
thread,  then , with a bit of luck, you should get an  exception in
the mail thread as its socket is ripped out from underneath it. In
the exception handler you can clean up, post 'failed' message,
whatever, & then free/exit/requeue your mail thread.

This works fine in TidTCPClient, TidFTP, TidHTML.  Should work in
SMTP but you'll have to try it.

Rgds,
Martin

Other Threads