Click to See Complete Forum and Search --> : ASP mail query


uvatha
04-26-2005, 09:37 AM
Hi,

First I should say Im not a programmer, and that a friend (who I have lost contact with) did this for me...so into the problem.

I wanted an ASP file to process a form and send information to the client and his prospective customer. I wanted to use ASP as it hides the email address in the asp file, making it more difficult, if not impossible for spam harvesters to 'grab' the email address. When I originally got it, it appeared to work, and I adjusted the coding as necessary for the various sites that I do - hobby and commercial.

After doing a recent commercial site I discovered that the ASP file returned this error on an Apache Server -
Method Not Allowed
The requested method POST is not allowed for the URL /dnabt/notears_enquiry.asp.

Apache/1.3.26 Server

Also, on a Windows 2003 server, the file process but does not send any messages as it should. Can anybody help?

The ASP file as follows:

<%
'====================================================================
' Good programming practice - ensures that you won't try to use a
' variable which hasn't been Dim'ed (dimensioned)
'====================================================================
Option Explicit

'====================================================================
' Initialise the variables required on the page
'====================================================================
Dim objMailMessage
Dim strMessageBody

'====================================================================
' Build the message body string
'====================================================================
strMessageBody = _
"<html>" & _
"<body>" & _
"<span style=""font: 12px Verdana;""><b>No Tears Website Enquiry</b><p>" & _
"Title : " & Request.Form("title") & "<br>" & _
"First Name : " & Request.Form("first_name") & "<br>" & _
"Last Name : " & Request.Form("last_name") & "<br>" & _
"Address : " & Request.Form("address") & "<br>" & _
"Post Code : " & Request.Form("postcode") & "<br>" & _
"Telephone No. : " & Request.Form("telno") & "<br>" & _
"Mobile No. : " & Request.Form("mobile") & "<br>" & _
"E-mail Address : " & Request.Form("email") & "<br>" & _
"Enquiry : " & Request.Form("enquiry") & "<br>" & _
"</span>" & vbCrLf & "</body>" & _
"</html>"

'====================================================================
' Create an instance of CDONTS E-mail Object
'====================================================================
Set objMailMessage = Server.CreateObject( "CDONTS.NewMail" )

'====================================================================
' Set the to and from addresses - from the website to Willy
'====================================================================
With( objMailMessage )
.To = "uvatha@ntlworld.com "
.From = Request.Form("email")

'================================================================
' Set the properties of the mail message - subject, body, format
'================================================================
.Subject = "No Tears Website Enquiry"
.Body = strMessageBody
.MailFormat = 0 ' HTML Message Format
.BodyFormat = 0
.Send
End With

'====================================================================
' After the Send method, NewMail Object becomes invalid
' Set it to VBScript constant of "Nothing" to release the memory
'====================================================================
Set objMailMessage = Nothing

'====================================================================
'====================================================================
' Create a new message to go to the person who submitted the order
'====================================================================
'====================================================================

'====================================================================
' Create an instance of CDONTS E-mail Object
'====================================================================
Set objMailMessage = Server.CreateObject( "CDONTS.NewMail" )

'====================================================================
' Re-initialise the message body
'====================================================================
strMessageBody = _
"<html>" & _
"<body>" & _
"<span style=""font: 12px Verdana;"">" & _
"Thank you for your enquiry. We reply as soon as possible.<p>" & _
"--<br>No Tears Computing<br>--"

'====================================================================
' Set the to and from addresses - from the website to enquirer
'====================================================================
With( objMailMessage )
.To = Request.Form("email")
.From = "notears@surfanytime.net"

'================================================================
' Set the properties of the mail message - subject, body, format
'================================================================
.Subject = "Thank you for your enquiry"
.Body = strMessageBody
.MailFormat = 0 ' HTML Message Format
.BodyFormat = 0
.Send
End With
%>
<script language="JavaScript">
window.close();
</script>

This acts on this file:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>www.notears.sathosting.net</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<META NAME="Keywords" CONTENT="Computer repairs, computer upgrades, graphics card, RAM, CPU, virus removal, data security, data protection,system efficiency, build computers">
<META NAME="Description" CONTENT="Computer repairs, computer upgrades, graphics card, RAM, CPU, virus removal, data security, data protection,system efficiency, build computers">
<META NAME="Author" CONTENT="uvatha@ntlworld.com">
<LINK REL="Stylesheet" TITLE="Default Stylesheet" MEDIA="Screen" HREF="notearstyle.css">
</head>

<body>
<div id="one">
<table width="800" height="300" border="0" align="center" cellpadding="1" cellspacing="0">
<tr>
<td align="center">&nbsp;</td>
<td height="11" align="center"><a name="top"></a></td>
<td align="center">&nbsp;</td>
</tr>
<tr>
<td width="180" align="center"><img src="images/Logo000B.jpg" width="105" height="101"></td>
<td width="470" align="center"><img src="images/Logo0000.jpg" width="214" height="71"></td>
<td width="180" align="center"><img src="images/gear.gif" width="115" height="50"></td>
</tr>
<tr align="left">
<td colspan="3" valign="top">
<form action="notears_enquiry.asp" method="post">
<table width="100%" border="0" cellspacing="0" cellpadding="0" align=center>

<TR>
<td width="100"><p align=right>Title:</p></td>
<td><SELECT name="title">
<option value="Mr" selected>Mr</option>
<option value="Mrs">Mrs</option>
<option value="Miss">Miss</option>
<option value="Ms">Ms</option>
<option value="Rev">Rev</option>
<option value="Dr">Dr</option>
</SELECT>
</td></TR>
<tr>
<td width="100" valign="top"><p align="right">First Name:</p>
</p></p></td>
<td valign="top">
<input name="first_name" size="25">
</td>
</tr>
<tr>
<td width="100"><p align="right">Last Name:</p></p></td>
<td valign="top">
<input name="last_name" size="25" maxlength="50">
</td>
</tr>
<tr>
<td width="100" valign="top"><p align="right">Address:</p></p></td>
<td valign="top">
<TEXTAREA name="address" rows="5" cols="40"></TEXTAREA>
</td>
</tr>
<tr>
<td width="100"><p align="right">Post Code:</p></p></td>
<td valign="top">
<input name="postcode" size="8">
</td>
</tr>
<tr>
<td width="100"><p align="right">Telephone:</p></p></td>
<td valign="top">
<input name="telno" size="12" maxlength="18">
</td>
</tr>
<tr>
<td width="100"><p align="right">Mobile:</p></p></td>
<td valign="top">
<input name="mobile" size="12" maxlength="18">
</td>
</tr>
<tr>
<td width="100"><p align="right">Email:</p></p></td>
<td valign="top">
<input name="email" size="25" maxlength="50">
</td>
</tr>
<tr>
<td width="100" valign="top"><p align="right">Enquiry:</p></td>
<td valign="top">
<TEXTAREA name="enquiry" cols="80" rows="8" id="enquiry"></TEXTAREA>
</td>
</tr>
</table>
<fieldset>
<table cellpadding="5" cellspacing="0" border="0" align="center">
<tr>
<td><input type="submit" value="Send Enquiry"></td>
<td><input type="reset" value="Reset Form"></td>
</tr>
</table>
</fieldset>
<p align="center">
<input type="button" value="Close Window" onClick="window.close()" style="color: #00005A; font-size: 12pt; font-weight: bold; font-family: Verdana; background-color: #ffffff">
</p>
</FORM></td>
</tr>
</table>
</div>
</body>
</html>

Can anybody help...sorry its so long...

Thanx in advance

Uvatha

phpnovice
04-26-2005, 09:49 AM
That code is written for the CDONTS mail object:

Set objMailMessage = Server.CreateObject( "CDONTS.NewMail" )

You either don't have authorization to use this object, or your server does not actually have that object. There are other possible mail objects which your server may support (particularly, Windows 2003):

CDOSYS
ASPmail
JMail
etc.

uvatha
04-26-2005, 11:21 AM
Thanks phpnovice. Where can I get a list of these mail objects and what servers support them?

Uvatha

phpnovice
04-26-2005, 11:58 AM
I know that Windows 2003 supports CDOSYS. The others are 3rd-party mail objects which may be added to a server. As for which mail object you have configured for use on your server, you would have to ask your server administrator or host.