Forum Moderators: open
Below is the script that one of the guys at the hosting company came up with, and it works. The problem is that I don't know how to get the form values from the contact page (Emailaddy, Subject, and Comments) to work in this script. Everything I try results in a 500 server error.
Any ideas?
******
<%
Set oMail = Server.CreateObject("CDO.Message")
Set oMailConfig = Server.CreateObject ("CDO.Configuration")
oMailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver")= "localhost"
oMailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport")= 8025
oMailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing")= 2
oMailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout")= 60
oMailConfig.Fields.Update
Set oMail.Configuration = oMailConfig
oMail.From = "somebody@somebody.com"
oMail.To = "somebody@someotherplace.com"
oMail.Subject = "From the contact page"
oMail.HTMLBody = "Subject: "
oMail.Send
Set oMail = Nothing
Set oMailConfig = Nothing
%>
<% response.redirect "contactthanks.html"
%>
<%
Option Explicit
dim sName, sEmail, sMessage
dim oCdoMail, oCdoConf, sConfURL
if Request.Form("Action") <> "" then
sName = Request.Form("Name")
sEmail = Request.Form("Email")
sMessage = Request.Form("Message") & VbCrLf
sMessage = sMessage & "<br><b>Company: </b>" & Request.Form("Company") & VbCrLf
sMessage = sMessage & "<br><b>Phone: </b>" & Request.Form("Phone") & VbCrLf
sMessage = sMessage & "<br><b>Address: </b>" & Request.Form("Address") & VbCrLf
sMessage = sMessage & "<br><b>City: </b>" & Request.Form("City") & VbCrLf
sMessage = sMessage & "<br><b>Prov: </b>" & Request.Form("Prov") & VbCrLf
sMessage = sMessage & "<br><b>Web: </b>" & Request.Form("Web")
Set oCdoMail = Server.CreateObject("CDO.Message")
Set oCdoConf = Server.CreateObject("CDO.Configuration")
sConfURL = "http://schemas.microsoft.com/cdo/configuration/"
with oCdoConf
.Fields.Item(sConfURL & "sendusing") = 2
.Fields.Item(sConfURL & "smtpserver") = "localhost"
.Fields.Item(sConfURL & "smtpserverport") = 25
.Fields.Update
end with
with oCdoMail
.From = sEmail
.To = "youremail@youraddress.com"
.Subject = "Contact Request"
.TextBody = sMessage
.HTMLBody = sMessage
.Configuration = oCdoConf
.Send
end with
Set oCdoConf = Nothing
Set oCdoMail = Nothing
response.write "Thank you for your message"
Response.Redirect "contactthanks.html"
else
%>
<form method="post" action="<%=Request.ServerVariables("SCRIPT_NAME")%>">
<p> </p>
<table width="730" border="0" align="center">
<tr>
<td colspan="2"> <p align="center" class="main"> </p>
<p align="center" class="main"><font face="Verdana, Arial, Helvetica, sans-serif"><strong>Contact
Us.</strong></font></p>
<div align="right"></div></td>
</tr>
<tr>
<td width="25%"><strong><font size="-1" face="Arial, Helvetica, sans-serif">Your
name:</font></strong></td>
<td width="75%" valign="top"> <input name="Name" type="text" value="-" size="60" />
</td>
</tr>
<tr>
<td width="25%"><strong><font size="-1" face="Arial, Helvetica, sans-serif">Your
company name:</font></strong></td>
<td width="75%" valign="top"> <input name="Company" type="text" value="-" size="70" /></td>
</tr>
<tr>
<td width="25%"><strong><font size="-1" face="Arial, Helvetica, sans-serif">Telephone:</font></strong></td>
<td width="75%" valign="top"> <input name="Phone" type="text" value="-" size="50" /></td>
</tr>
<tr>
<td width="25%"><strong><font size="-1" face="Arial, Helvetica, sans-serif">Address:</font></strong></td>
<td width="75%" valign="top"> <input name="Address" type="text" id="Address2" value="-" size="70" /></td>
</tr>
<tr>
<td width="25%"><strong><font size="-1" face="Arial, Helvetica, sans-serif">City:</font></strong></td>
<td width="75%" valign="top"> <input name="City" type="text" id="City2" value="-" size="70" /></td>
</tr>
<tr>
<td width="25%"><strong><font size="-1" face="Arial, Helvetica, sans-serif">Province/State:
</font></strong></td>
<td width="75%" valign="top"> <input name="Prov" type="text" id="Prov2" value="-" size="70" /></td>
</tr>
<tr>
<td width="25%"><strong><font size="-1" face="Arial, Helvetica, sans-serif">email:</font></strong></td>
<td width="75%" valign="top"> <input name="Email" type="text" value="-" size="70" /></td>
</tr>
<tr>
<td width="25%"><strong><font size="-1" face="Arial, Helvetica, sans-serif">website
address:</font></strong></td>
<td width="75%" valign="top"> <input name="Web" type="text" id="Web2" value="-" size="70" /></td>
</tr>
<tr>
<td width="25%"><strong><font size="-1" face="Arial, Helvetica, sans-serif">Your
questions/concerns:</font></strong></td>
<td width="75%" valign="top"> <textarea name="Message" cols="60" rows="6">-</textarea></td>
</tr>
<tr>
<td width="25%"> </td>
<td width="75%" valign="top"> <input type="submit" name="Action" value="Send" /></td>
</tr>
</table>
<p> </p>
<%
end if
%>
For whatever reason, the script doesn't work.
For years, I've used very simple, off-the-shelf CDONTS and CDOSYS scripts with no problems.
Since my brand-new site was put on a Plesk server, nothing works. I've spent the entire holiday weekend trying to find a script that works.
If anyone has experience with CDOSYS on a Plesk server, and knows how to write a working script, please IM me. If you require payment, that's fine. I just want to get this working!
If you don't, it has to do with the security of your server. Some servers do not send emails from non-existing emails.
I know other email programs need the password included, but I am not sure about cdosys
Then I took at look at the form he created on a separate page. None of the text field names had quotation marks around them. For example, my text field looked like this: <input type="text" name="emailaddy2">. His looked like this: <input type=text name=emailaddy2>
I have no idea why the quotation marks made the difference, as I've used the same formatting for forms for years, and never had a problem with CDONTS or CDOSYS scripts.
At least it's fixed.