// See if they have submitted or just need the form
if(request.method == "POST"){
// Create an instance of the SendMail object
var myMail = new SendMail();
// Assign the properties their values
myMail.To = request.toAddress;
myMail.From = request.fromAddress;
myMail.Subject = request.subject;
myMail.Body = request.body;
myMail.Smtpserver = "mail.purejavascript.com";
myMail.Errorsto = "errors@purejavascript.com"
// Try to send the mail.
if(!myMail.send()){
// If there was an error, give the user the e-mail address of who they
// should contact about the error, as well as the error code and message.
write("There was an error sending your message. Please send e-mail to ");
write(myMail.Errorsto + " with the following error message ");
write("Error " + myMail.errorCode() + ": " + myMail.errorMessage());
}else{
// If there was not an error, tell the user they were successful.
write("Your message was sent successfully!");
}
}else{
// If this page was called and a form was not submitted, then write the
// e-mail form to the page for the user to use.
write('');
}