Home Guides Glossary

Create an ASP Form Mailer

Some of the information in this article is advanced material we make available as a courtesy. Please be advised that you are responsible for properly following the procedures below. Customer Support cannot assist with these topics.

To use an ASP form-mailer on a Windows Dedicated or Virtual Private Server (VPS), create a Web form in HTML that links to an ASP file, then upload it to your server. An example script is seen below:

<%
'Form should include a hidden field named redirect otherwise the user will be redirected to the home page

'Required settings - these must be set for this script to work
mail_to = "mary@secureserver.net"
mail_from = "test@secureserver.net"

On Error Resume Next

host_url = Request.ServerVariables("HTTP_HOST")
req_method = Request.ServerVariables("REQUEST_METHOD")

mail_body = vbCrLf

'Gather form submission items and translate into message body
If err.number <> 0 Then
Response.Write "Error processing mail request. Error code: " & err.number
Else
If (req_method = "GET") Then
For Each Item In request.QueryString
If item <> "" Then
key = item
value = Request.QueryString(item)
If(lcase(key) = "redirect") Then
landing_page = value
Else
mail_body = mail_body + ucase(key) + ": " + value + vbCrLf
End If
End If
Next
ElseIf (req_method = "POST") Then
For Each Item In request.form
If item <> "" Then
key = item
value = Request.Form(item)
If(lcase(key) = "redirect") Then
landing_page = value
Else
mail_body = mail_body + ucase(key) + " " + value + vbCrLf
End If
End If
Next
End If
End If

'Generate mail message.
If err.number <> 0 Then Response.Write "Error processing mail request. Error code: " & err.number Else Set msg = Server.CreateObject("CDO.Message") Set myCon = Server.CreateObject ("CDO.Configuration") 'Out going SMTP server myCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "localhost" myCon.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 myCon.Fields.Update msg.Configuration = myCon msg.Subject = "Message from " & host_url msg.From = mail_from msg.To = mail_to msg.TextBody = mail_body msg.Send Set msg = Nothing End If If err.number <> 0 Then Response.Write "Error processing mail request. Error code: " & err.number Else If landing_page <> "" Then Response.Redirect landing_page Else Response.Redirect host_url End If End If %>

Domain Registration

Pay less for website domain names. Register your own .com, .net or .org for as low as $10.18 per year. We have everything you need to get online with your new domain.

Website Builder

Build an amazing website in just under an hour with Website Builder. Take advantage of designs created just for your industry and then customize them to reflect your one-of-a-kind idea.

Website Security

Protect your website and keep customers safe. Your comprehensive Website Security solution. Get peace of mind by securing your websites.

cPanel Hosting

Everything needed to give your website the high-performance home it deserves.  Protect transactions and secure your customer's data with a SSL Certificate
Copyright © 2005 - 2024.  All rights reserved.  Privacy Policy