I did a send e mail control application and when I run it within onValidateSuccess code it sends the mail but then ... the application goes stucked. No way to go back or exit from it

This is the code for showing messages after sending but probably something is wrong.

sc_mail_send($mail_smtp_server,
$mail_smtp_user,
$mail_smtp_pass,
$mail_from,
$mail_to,
$mail_subject,
$mail_message,
$mail_format,
$mail_copies,
$mail_tp_copies,
$mail_port,
$mail_tp_connection,
$mail_attachments)
;


if ({sc_mail_ok})
{
sc_alert({lang_mail_sended_ok} );
//echo {lang_mail_sended_ok} ;
}
else
{
sc_erro_mensagem({sc_mail_erro});
}

If I comment the message part of code it works so I suppose the error will be there....
How can I show a message that mail was sent successfully ?? or error
I checked also all message in language and they all exist.

/*

if ({sc_mail_ok})
{
sc_alert({lang_mail_sended_ok} );
//echo {lang_mail_sended_ok} ;
}
else
{
sc_erro_mensagem({sc_mail_erro});
}

*/