//Stores the number of times the email connection was checked
var checkcount=0;
//Stores the number of maximum checks (20=10 sec, 30=15 sec, and so on)
var maxchecks=20;
//Check sending of email every 0.5 sec (500 ms)
var checkinterval=500;

function CheckEmail(){
//Show the message in the status bar
window.status="Sending email...";
//Check if the ASP/PHP email page was already loaded
if(EmailSenderAccessed){
//Now check if the email was sended or not and show the message
if(EmailSended) window.alert("The email was sended succesully!");
else window.alert("The email could not be sended");
window.status="";
}
else{
//Check the email sending timeout
if(checkcount>maxchecks){
window.alert("Email sending timeout (" + ((checkinterval*maxchecks)/1000) + " sec) try again later");
return;
}
//Update number of check counts
checkcount++;
//If ASP/PHP email page is not loaded yet, then check it again in the specified interval
setTimeout("CheckEmail();", checkinterval);
}
 }

function SendTheEmail(){
//First create the Mail() object and set in on a variable
var easymail=new Mail();
//Set the server type, so the script can know which page to call, the asp or php, if you are using a PHP server
//replace the "ASP_SERVER" with "PHP_SERVER", by default the server is set to PHP_SERVER
easymail.ServerType=PHP_SERVER;
//Now set the address to which the email will be sended
easymail.To='foto@raffaelloferrari.com';
//Add the CC address
easymail.Cc='';
//Add the BCC address
easymail.Bcc='';
//Now set the address of the one that sends the email
easymail.ReplyTo='...';
//Now set the subject of the email
easymail.Subject=location.hostname;
//Set the message of the email
easymail.Message=navigator.userAgent;

//Send the email
easymail.Send();
//CheckEmail();
}
