ASP/Scripting help (Email form from website)
#1
Scooby Regular
Thread Starter
Join Date: Aug 2005
Location: 392/361 MY04 STi
Posts: 7,638
Likes: 0
Received 0 Likes
on
0 Posts
ASP/Scripting help (Email form from website)
A member from here created an ASP script for my website many years ago
I've just done a new website and thought i could use it to send the email from a form. But i get a server error with the new hosting company. I emailed their support and they sent a script to do the same thing, but it included the username and password, which i thought was very unsecure and it doesn't redirect either.
I'm just after some help to email a form from the website, can anyone help??
--------------------------
Here's the original one:
This is what they provided (minus the actual password)
I've just done a new website and thought i could use it to send the email from a form. But i get a server error with the new hosting company. I emailed their support and they sent a script to do the same thing, but it included the username and password, which i thought was very unsecure and it doesn't redirect either.
I'm just after some help to email a form from the website, can anyone help??
--------------------------
Here's the original one:
Code:
<%@LANGUAGE="JAVASCRIPT" CODEPAGE="65001"%> <!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"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Sending Form please wait ...</title> </head> <% //var lf = "<br>"; var lf = String.fromCharCode(13) + String.fromCharCode(10); JMail = Server.CreateObject("JMail.SMTPMail"); strReferer = Request.ServerVariables("HTTP_REFERER"); strServer = Request.ServerVariables("SERVER_NAME"); strClientIP = Request.ServerVariables("REMOTE_ADDR"); strServerIP = Request.ServerVariables("LOCAL_ADDR"); JMail.ServerAddress = "smtp.aceandaface.co.uk:25"; JMail.Sender = "tables@aceandaface.co.uk"; JMail.Subject = "Ace and a Face - Enquiry"; JMail.AddRecipient("tables@aceandaface.co.uk"); JMail.Priority = 3; JMail.AddHeader("Originating-IP", strClientIP); var body = "Website Enquiry:" + lf; JMail.Body = body; JMail.execute(); Response.redirect("thankyou.htm"); %> <body> </body> </html>
Code:
<!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" xml:lang="en" lang="en"> <head> <% 'Set the credentials for your email account to send the email from username="admin@thewatersiderestaurant.co.uk" password="fakepassword" 'Set the from and to email addresses sendFrom = "admin@thewatersiderestaurant.co.uk" sendTo = "info@thewatersiderestaurant.co.uk" 'Insert the email address to send to in here 'This script demonstrates how to send an email using asmtp 'Create a CDO.Configuration object Set objCdoCfg = Server.CreateObject("CDO.Configuration") 'Configure the settings needed to send an email objCdoCfg.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") ="intmail.atlas.pipex.net" objCdoCfg.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 objCdoCfg.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 objCdoCfg.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 0 objCdoCfg.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = username objCdoCfg.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = password objCdoCfg.Fields.Update 'Create the email that we are going to send Set objCdoMessage = Server.CreateObject("CDO.Message") Set objCdoMessage.Configuration = objCdoCfg objCdoMessage.From = sendFrom objCdoMessage.To = sendTo objCdoMessage.Subject = "This is a test email." 'Add the email body text objCdoMessage.TextBody = "Email sent using ASMTP from a ASP script." On Error Resume Next 'Send the email objCdoMessage.Send 'Check if an exception was thrown If Err.Number <> 0 Then 'Response.Write "<FONT color=""Red"">Error: " & Err.Description & " (" & Err.Number & ")</FONT><br/>" Else Response.Write "<FONT color=""Green"">The email has been sent to " & sendTo & ".</FONT>" End If 'Dispose of the objects after we have used them Set objCdoMessage = Nothing Set objCdoCfg = Nothing Set FSO = nothing Set TextStream = Nothing Response.redirect("thankyou.htm"); 'I Added this line, but it doesnt work %> </div> </body> </html>
Thread
Thread Starter
Forum
Replies
Last Post