Form to Email Tutorial
Quick
Overview:
A very common task for many websites is a form that submits
its results to an email account. We commonly refer to this
task as form to email. There are several ways to add form
to email to your website(s) hosted at AUWEB. You can use Perl(Unix),
ASP, or Cold Fusion to accomplish the task. This web page
explains how to send email using each of those three popular
technologies.
Perl
based form to email:
One
of the most popular tools for accomplishing the form to email
task is formmail.pl from Matt Wright's Script Archive. This
script was written for Unix, There are a few things to keep
in mind when using a Unix based perl script at AUWEB.
1)
CHMOD scripts to 755. Just place them in the cgi-bin directory
or any other.
2) Perl path /usr/bin/perl.
3) Some pathnames will need to be changed, since the
directory structures may differ.
4) Perl scripts must end in .pl or .cgi
5) $mailprog = '/usr/sbin/sendmail';
ASP
based form to email:
At Windows based hosts , ASP can be used to accomplish the
task of form to email. At AUWEB, we do not promote CDONTS.
For sending email via ASP, we support ASPEmail and OXCMAil.
Here is a code sample for sending email from an ASP page at
AUWEB.
<%
Set Mailer = Server.CreateObject("ASPMAIL.ASPMailCtrl.1")
recipient = Request.Form("recipient")
sender = Request.Form("sender")
subject = Request.Form("subject")
message = Request.Form("messageline1")
message = message & vbCRLF
message = message & vbCRLF
message = message & Request.Form("messageline2")
' insert your mail server here
mailserver = "your.mailserver.com"
result = mailer.SendMail(mailserver, recipient, sender, subject,
message)
%>
<% If "" = result Then %>
Mail has been sent.
<% Else %>
Mail was not sent, error message is
<H2>
<%= result %>
</H2>
<% End If %>
Please see http://www.flicks.com/ASPMail/intro.htm
Cold Fusion based form to email:
If you prefer to code your pages in Cold Fusion, you can use
Cold Fusion to accomplish the task of form to email. Cold
Fusion uses the CFMAIL command to send email. The following
code could be used within a Cold Fusion page to send email.
<CFMAIL
FROM="#MailFrom#" TO="#MailTo#" SUBJECT="#Subject#">
#MailMessage#
</CFMAIL>
Important
Things to Consider:
When sending email at AUWEB, the AUWEB email servers will
not allow email to relay unless the FROM or TO address in
the email is a valid local email address. If your form to
email page appears to work, but the email never arrives at
the destination, check to make sure either the FROM or TO
address is a valid local email address at AUWEB.
In
the ASP based form to email example, we list 127.0.0.1 as
the outbound SMTP server to use. Each web server at AUWEB
has a simple outbound SMTP relay installed. For optimal effeciency
and reliability, we strongly urge you to use 127.0.0.1 as
the outbound SMTP server in your scripts instead of mail.yourname.com
or IP Address. By default, sendmail and Cold Fusion also use
127.0.0.1.
Please
remember that our email servers are not to be used as spam
cannons. Do not write a script that sends lots of spam. Sending
spam through our servers wastes CPU time and bandwidth, and
can degrade performance. Any script being used to cannon spam
will be instantly removed without any warning.