Unable to send email from website

I need to let users send email from our website's contact form. Our website is hosted on myhosting.com. I am using the attached code to send email.
The send() method is failing and returning the error "An error occured. Please contact the webmaster of this site."

Is this because our host server (myhosting.com) is not allowing us to send email or something in the code?
We have our own exchange server. Can I make use of our exchange server to send email while the website resides on myhosting (like using smtp) ?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/main.dwt" codeOutsideHTMLIsLocked="false" -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<style type="text/css">
.style3 {color: #0F5A7A}
.style4 {font-size: 12px}
.style5 {
	font-size: 14px;
	color: #333333;
<script language="javascript">
function MM_validateForm() { //v4.0
  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
      if (val) { nm=val.name; if ((val=val.value)!="") {
        if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
          if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
        } else if (test!='R') { num = parseFloat(val);
          if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
          if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
            min=test.substring(8,p); max=test.substring(p+1);
            if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
      } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
    } if (errors) alert('The following error(s) occurred:\n'+errors);
    document.MM_returnValue = (errors == '');
} }
<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>


<table width="100%" border="0" cellpadding="0" cellspacing="0" class="backgr">
              <p class="style4"><strong>Thank You ! <br/>
              The email has been sent.</strong></p>
<!-- InstanceEnd -->
Dim name, email, message, NewMailObj

'create the mail object and send the details
Set NewMailObj=Server.CreateObject("JMail.Message")
NewMailObj.Logging = true
NewMailObj.silent = true
NewMailObj.From = email
NewMailObj.FromName = name
NewMailObj.Subject = "Website Contact Form" 
NewMailObj.Body = message 

'you need to add the following lines FOR the mail to be sent in HTML format
'NewMailObj.BodyFormat = 0 
'NewMailObj.MailFormat = 0 
if not NewMailObj.Send("mail.mydomain.com") then
Response.write "An error occured. Please contact the webmaster of this site."
'Close the email object and free up resources 
Set NewMailObj = nothing
Response.write "The email was sent."
end if
%>  </html>

Open in new window

Who is Participating?
Hi Angel,

The problem possibly lies in line 66 - mail.mydomain.com. This looks like example code (unless you replaced that for posting on EE); that should be replaced with an actual mail server - so, if your Exchange has an SMTP address you can use. Alternatively, you might find that 'myhosting.com' allow you to send through their server - you could try removing the "mail.mydomain.com" altogether and leave it blank - it will probably try and use the local host.

Alternatively, you might need a username and password for the myhosting.com mail server; a lot of hosting companies require this. Might be worth poking around on their support pages to see anyone else has tried to do the same thing...

Hope that helps a bit!
Set NewMailObj.silent to false so you can see the actual error message.
Angel02Author Commented:
I set NewMailObj.silent = false, and got the following error at line 66 - mail.mydomain.com

jmail.Message error '8000ffff'
The message was undeliverable. All servers failed to receive the message

In mail.mydomain.com, I first used the domainname assigned to us by myhosting.com. Now I am using our exchange SMTP address. Both are giving the same error stated above.

I think there will be additional charegs if we want to use the exchange provided by myhosting.com. But we have our own exchange, which we would want to use.
Angel02Author Commented:
Hello Again.
So, I was in contact with my hosting company and they provided me the solution. One was to follow the instructions at http://myhosting.com/wiki/Email_Form_Processor and then was to use only our own domain's SMTP server (smtp.<our_domainname_assigned_by_myhosting>.com)

The problem is that it works fine and I receive email if the recipient is ***@gmail.com or ***@yahoo.com.
But I am getting the undelivered error (jmail.Message error '8000ffff') when I try to send it to my work email. Is it something with our work place email policies ? Please help !
Angel02Author Commented:
The initial problem was solved but a consequent issue was raised, which did not receive any response. I figured it out gradually.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.