Forum Moderators: open

Message Too Old, No Replies

Help with cdosys script

On Plesk server

         

dickbaker

10:15 pm on May 27, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



My hosting company put my new site on a Plesk server. I've used a cdosys script in the past with success, but it doesn't work on the new server.

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"
%>

dickbaker

9:04 pm on May 28, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Anybody?

malinkacc

12:44 am on May 29, 2007 (gmt 0)

10+ Year Member



Here is what we use for standard contact form, modify to your needs, this all goes on one page and you redirect to thank you page (already modified for your page), good luck:

<%

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>&nbsp;</p>

<table width="730" border="0" align="center">
<tr>
<td colspan="2"> <p align="center" class="main">&nbsp;</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%">&nbsp;</td>
<td width="75%" valign="top"> <input type="submit" name="Action" value="Send" /></td>
</tr>
</table>

<p>&nbsp;</p>
<%
end if
%>

dickbaker

2:59 am on May 29, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thank you, malinkacc.

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!

bmcgee

4:49 am on May 29, 2007 (gmt 0)

10+ Year Member



Why don't you try debugging it by taking the sample that works and add in one field at a time into the body. Then you can see the single change that made it go bad.

Resolve it from there...

dickbaker

5:05 am on May 29, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



bmcgee, I've already done that.

In the line, oMail.From = "somebody@somebody.com" , I replaced the "somebody@somebody.com" with Request.Form("emailaddy2").

I get a 500 server error.

There must be 5,000 different CDOSYS scripts out there, but none of them address this issue.

malinkacc

9:32 am on May 29, 2007 (gmt 0)

10+ Year Member



Check your server logs, 500 server error doesn't tell you much.

defanjos

3:01 pm on May 29, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Try assigning to Request.Form("emailaddy2") an email address setup on your site. For example, you@yoursite.com. Do you still get the error?

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

dickbaker

9:49 pm on May 29, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well, the guy from the hosting company came through with a working script. At first, I couldn't figure out what I had done wrong, because he was doing the same thing I was: putting Request.Form("emailaddy2") in "from" line.

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.