SMTP New transporter: my mouse cursor turns into a spinning color wheel

Hi guys,

I run this code to rely on a SMTP server whose IP can not be reached:

C_OBJECT($O_Transporter;$O_Status)
$O_Transporter:=SMTP New transporter($O_Server)
$O_Status:=$O_Transporter.checkConnection()
$B_is_SMTP:=$O_Status.success

Because the IP is wrong, Apple shows a spinning beach ball, funny on a beach not on a computer.

Is there a way to avoid it?

tx

Hello,

You can reduce the connection timeout. This way:

C_OBJECT($O_Transporter;$O_Status)
$O_Server.connectionTimeOut:=2// in seconds
$O_Transporter:=SMTP New transporter($O_Server)
$O_Status:=$O_Transporter.checkConnection()
$B_is_SMTP:=$O_Status.success

Regards
Yannick

You can also delegate the mail sending to a (preferably preemptive) worker.

For example you could have a worker like…

C_OBJECT($1;$smtp;$2;$mail;$3;$formula;$4;$this)

$smtp:=$1
$mail:=$2
$formula:=$3
$this:=$4

C_OBJECT($status)

ON ERR CALL("on_mail_exception")

$status:=SMTP New transporter($smtp).send($mail)

ON ERR CALL("")

If ($formula#Null)
	If (JSON Stringify($formula)="\"[object Formula]\"")
		$formula.call($this;$status)
	End if 
End if 

KILL WORKER

and write a “my_send_mail_method” like so

C_OBJECT($1;$smtp;$2;$mail;$3;$formula;$4;$this)

$smtp:=$1
$mail:=$2
$formula:=$3
$this:=$4

$workerName:="mail"+"@"+Generate UUID

CALL WORKER($workerName;"smtp_p";$smtp;$mail;$formula;$this)

then you can send mail like

my_send_mail_method($smtp;$mail;Formula(MY_CALL_BACK_METHOD );$ctx)