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" -->
<head>
<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;
}
</style>
<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>
<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
</head>

<body>

<table width="100%" border="0" cellpadding="0" cellspacing="0" class="backgr">
              <tr>
              <td>
              <p class="style4"><strong>Thank You ! <br/>
              The email has been sent.</strong></p>
              </td>
              </tr>
          </table>
 </body>
<!-- InstanceEnd -->
<%
Dim name, email, message, NewMailObj
name=request.form("textBoxName")
email=request.form("textBoxEmail")
message=request.form("textBoxMessage")

'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.AddRecipient("myemail@gmail.com")
NewMailObj.AddRecipient("myemail@yahoo.com")
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."
else
'Close the email object and free up resources 
Set NewMailObj = nothing
Response.write "The email was sent."
end if
%>  </html>

Open in new window

Angel02Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Fuzzyfish1000Commented:
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!
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ChetOS82Commented:
Set NewMailObj.silent to false so you can see the actual error message.
0
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.
0
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 !
0
Angel02Author Commented:
The initial problem was solved but a consequent issue was raised, which did not receive any response. I figured it out gradually.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Email Clients

From novice to tech pro — start learning today.