Page 1 of 1

AbortMail()

Posted: Sun Apr 30, 2023 11:17 am
by wayne-c
Howdy

I am sending asynchronous mail and want to timeout after 15s - how to abort the operation? There is AbortFTPFile() and AbortHTTP() but no AbortMail()?

Code: Select all

Timeout = ElapsedMilliseconds() + 15000

Result = SendMail(0, "smtp.free.fr", 25, #PB_Mail_Asynchronous)
Repeat
	Progress = MailProgress(0)
	Delay(300)
	If ElapsedMilliseconds() > Timeout
		AbortMail(0) ; <-- Does not exist?!
		Break
	EndIf
Until Progress = #PB_Mail_Finished Or Progress = #PB_Mail_Error

If Progress = #PB_Mail_Finished
	MessageRequester("Information", "Mail correctly sent !")
Else
	MessageRequester("Error", "Can't sent the mail !")
EndIf
Or why not a Timeout parameter directly in the SendMail()-Function?

Re: AbortMail()

Posted: Sun Apr 30, 2023 1:47 pm
by jassing
FreeMail() won't end it?

Re: AbortMail()

Posted: Sun Apr 30, 2023 2:07 pm
by wayne-c
Well it might do it, but I am not sure - should be confirmed by @Fred. I'd prefer a real AbortMail() function that then gives #PB_Mail_Aborted as return value of MailProgress()

Re: AbortMail()

Posted: Sun Apr 30, 2023 4:34 pm
by infratec
There should be send a RSET command maybe followed bye a QUIT.
I don't think that FreeMail() does this.

If you really need this ... libcurl.

Re: AbortMail()

Posted: Sun Apr 30, 2023 4:41 pm
by wayne-c
infratec wrote: Sun Apr 30, 2023 4:34 pm There should be send a RSET command maybe followed bye a QUIT.
I don't think that FreeMail() does this.

If you really need this ... libcurl.
We move this to Features and Requests?

Re: AbortMail()

Posted: Mon May 01, 2023 3:19 am
by idle
Would be a good to add, but it mightn't be necessary as the rfc says
There are circumstances, contrary to the intent of this
specification, in which an SMTP server may receive an indication that
the underlying TCP connection has been closed or reset. To preserve
the robustness of the mail system, SMTP servers SHOULD be prepared
for this condition and SHOULD treat it as if a QUIT had been received
before the connection disappeared.

https://www.rfc-editor.org/rfc/rfc5321. ... on-4.1.1.5