<script language="JavaScript1.1" src="../javascript/emailer.js"></script>
</p>
<form name="emailForm">
<table border="0" width="572" cellspacing="2"
cellpadding="1" height="163">
<tr>
<td bgcolor="#dcdcdc" width="142">
<p>Full Name</p>
</td>
<td><input name="First_Name" size="15"
type="text">
<input name="Middle_Initial" size="2"
maxlength="1" type="text">
<input name="Last_Name" size="37"
type="text"></td>
</tr>
<tr>
<td bgcolor="white" width="142">
<p>Subject</p>
</td>
<td><input name="Subject" size="39" type="text">
</td>
</tr>
<tr>
<td bgcolor="#dcdcdc" width="142">
<p>Email Address</p>
</td>
<td><input name="Email_Address" size="39" type="text"></td>
</tr>
<tr>
<td colspan="2"><font size="2"><textarea name="Comments" rows="15"
cols="70" wrap="virtual">
Your questions or comments go here.</textarea></font></td>
</tr>
<tr bgcolor="white">
<td colspan="2" bgcolor="white"><b>Click <input type="button"
value="Finish" onclick=ShowEmail()>
to preview your email.</b></td>
</tr>
</table>
</form>
/* Dave writes too much code ;p */
// This function only allows numbers, letters, and characters that do not
//interfere with the code
function validated(string) {
for (var i=0, output='', valid=" '0123456789abcdefghijklmnopqrstuvwxyz
ABCDEFGHIJKLMNOPQRSTUVWXYZ.,/?
[]-=_+!@#$%&()<>:"; i<string.length; i++)
if (valid.indexOf(string.charAt(i)) != -1){
if (valid.indexOf(string.charAt(i)) == '1'){
output += '\''
continue;
}
output += string.charAt(i)
}
return output;
}
// This function is almost identical with validated above, but replaces spaces
with underscores for naming purposes.
function valname(string) {
for (var i=0, output='', valid=" '0123456789abcdefghijklmnopqrstuvwxyz
ABCDEFGHIJKLMNOPQRSTUVWXYZ.,/?
[]-=_+!@#$%&()<>:"; i<string.length; i++)
if (valid.indexOf(string.charAt(i)) != -1){
if (valid.indexOf(string.charAt(i)) == 0){
output += "_"
continue;
}
if (valid.indexOf(string.charAt(i)) == '1'){
output += '\''
continue;
}
output += string.charAt(i)
}
return output;
}
function valcom(string) {
for (var i=0, output='', valid=" '\"&\n0123456789abcdefghijklmnopqrstuvwxyz
ABCDEFGHIJKLMNOPQRSTUVWXYZ.,?[]-=_+!@%()<>:"; i<string.length; i++)
if (valid.indexOf(string.charAt(i)) != -1){
if (valid.indexOf(string.charAt(i)) == '1'){
output += '\''
continue;
}
if (valid.indexOf(string.charAt(i)) == '2'){
output += '\'\''
continue;
}
if (valid.indexOf(string.charAt(i)) == '3'){
output += '\&'
continue;
}
if (valid.indexOf(string.charAt(i)) == '4'){
output += '<br>'
continue;
}
output += string.charAt(i)
}
return output;
}
function ShowEmail(First_Name, Email_Address, Comments){
First_Name = validated(document.emailForm.First_Name.value)
Middle_Initial = validated(document.emailForm.Middle_Initial.value)
Last_Name = valname(document.emailForm.Last_Name.value)
Email_Address = validated(document.emailForm.Email_Address.value)
Comments = valcom(document.emailForm.Comments.value)
Subject = validated(document.emailForm.Subject.value)
EmailCreate=window.open("","email_preview","HEIGHT=300,WIDTH=500,
scrollbars=yes,resizable=yes,top=10,left=200");
EmailCreate.document.write
("<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\r");
EmailCreate.document.write ("<html>\r");
EmailCreate.document.write ("\t<head>\r");
EmailCreate.document.write ("\t\t<title>ATACards.com Email Confirmation</title>\r");
EmailCreate.document.write ("\t\t<meta HTTP-EQUIV=\" pragma\" CONTENT=\"no-cache\">\r");
EmailCreate.document.write ("\t\t<meta NAME=\"copyright\" content=\"©
Copyright 2004 by Burkey & Leverich, ATACards.com\">\r");
EmailCreate.document.write ("\t\t<meta NAME=\"author\"
content=\"ATACards.com, David Leverich\">\r");
EmailCreate.document.write ("\t\t<meta NAME=\"GENERATOR\"
CONTENT=\"This page was created by custom ATAcards.com
Javascript, creating each page dynamically.\">\r");
EmailCreate.document.write ("\t\t
<link href=\"http://www.atacards.com/styles/style.css..." rel=\"stylesheet\"
media=\"screen\">\r\t</head>\r");
EmailCreate.document.write ("\r");
EmailCreate.document.write ("\t<body BGCOLOR=\"white\"
onload=\"window.focus();\">\r");
EmailCreate.document.write ("\t\t<div align=\"center\">\r");
EmailCreate.document.write ("<img src=\"http://www.atacards.com/images/ATAC_logo..."
alt=\"ATAcards.com -
Your source for proffessional
ATA Business Cards\"><p> </p>\r");
EmailCreate.document.write ("\t\t<table width=\"480\"
border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\r");
EmailCreate.document.write ("\t\t<tr bgcolor=\"orange\"><td><P class=\"smaller\">
<b>Please check your email information, if it is accurate,
click below.</b></p></td></tr>\r");
EmailCreate.document.write ("\t\t\t<tr bgcolor=\"#dcdcdc\">
<td><p class=\"smaller\">Name: ");
// Error handling, this disallows the order without at least an initial
if (First_Name == ""){
EmailCreate.document.write ("(<font color=\"red\"><b>Name?</b></font>)");
}
else {
EmailCreate.document.write (First_Name, " ");
}
// This just puts punctuation and spacing after a middle initial if it's found
if (Middle_Initial == ""){
}
else {
EmailCreate.document.write (Middle_Initial, ". ");
}
// Again, no last name, it barfs
if (Last_Name == ""){
EmailCreate.document.write ("(<font color=\"red\"><b>Last Name?</b></font>)");
}
else {
EmailCreate.document.write (Last_Name);
}
EmailCreate.document.write ("</p></td></tr>\r");
EmailCreate.document.write ("\t\t\t\t<tr bgcolor=\"white\">
<td><p class=\"smaller\">Email Address: ");
// Let's the customer know that the email address was omitted,
//they then need the shipping email below
if (Email_Address == ""){
EmailCreate.document.write ("(<font color=\"red\"><b>Reply Email Required</b></font>)");
}
else{
EmailCreate.document.write (Email_Address);
}
EmailCreate.document.write ("</p></td></tr>\r");
EmailCreate.document.write ("\t\t\t\t
<tr bgcolor=\"#dcdcdc\"><td><p class=\"smaller\">Email Subject: ");
// Let's the customer know that the email address was omitted,
// they then need the shipping email below
if (Subject == ""){
EmailCreate.document.write ("ATAcards Contact - No subject");
}
else{
EmailCreate.document.write ("ATAcards.com - ", Subject);
}
EmailCreate.document.write ("</p></td></tr>\r");
EmailCreate.document.write ("\t\t\t<tr><td><fieldset><legend>Email Content:</legend>\r");
EmailCreate.document.write ("\t\t\t\t<p class=\"smaller\">");
if (Comments == ""){
EmailCreate.document.write ("(<font color=\"red\">
<b>Email Content Required</b></font>)");
}
else {
EmailCreate.document.write ("<div align=\"center\"><table width=\"400\">
<tr><td><p class=\"noindentsmaller\">",
Comments, "</p></td></tr></table><\div>\n");
}
EmailCreate.document.write ("</p></fieldset><br></td></tr>\r");
EmailCreate.document.write ("\t\t<tr bgcolor=\"orange\"><td>
<P class=\"smaller\"><b>If you wish to <a onclick=\"window.blur()\">change</a>
this email information, <br>make necessary changes on email
form and re-click 'Finish' to change your email.</b></p></td></tr></table>\r");
EmailCreate.document.write ("<form name=\"email_form\"\r");
EmailCreate.document.write ("action=\"/cgi-bin/emailer.cgi\" method=\"POST\">\r");
EmailCreate.document.write ("<INPUT TYPE=\"hidden\" NAME=\"First_Name\"
VALUE=\"", First_Name, "\">\r");
EmailCreate.document.write ("<INPUT TYPE=\"hidden\" NAME=\"Middle_Initial\"
VALUE=\"", Middle_Initial, "\">\r");
EmailCreate.document.write ("<INPUT TYPE=\"hidden\" NAME=\"Last_Name\"
VALUE=\"", Last_Name, "\">\r");
EmailCreate.document.write ("<INPUT TYPE=\"hidden\" NAME=\"nameField\"
VALUE=\"", Last_Name, ", ", First_Name, " ", Middle_Initial, ". ", "\">\r");
EmailCreate.document.write ("<INPUT TYPE=\"hidden\" NAME=\"Comments\"
VALUE=\"", Comments, "\">\r");
EmailCreate.document.write ("<INPUT TYPE=\"hidden\" NAME=\"Email_Address\"
VALUE=\"", Email_Address, "\">\r");
EmailCreate.document.write ("<INPUT TYPE=\"hidden\" NAME=\"Subject\" VALUE=\"",
Subject, "\">\r");
EmailCreate.document.write ("<center><INPUT TYPE=\"submit\"
VALUE=\"Send your email to ATAcards!\"></center>\r");
EmailCreate.document.write ("</form>\r");
EmailCreate.document.write ("\t\t</div>\r");
EmailCreate.document.write ("\t</body>\r");
EmailCreate.document.write ("</html>\r");
EmailCreate.document.close();
return false;
}
#!/usr/bin/perl
use CGI ':standard';
use CGI::Carp qw(fatalsToBrowser);
######################## Program Header #########################################
##
## Copyright (C) 2004 Poetic Pollution
## Script Name: BareBonesMailer
## Version: 0.2.2
## URL: http://poeticpollution.net/scripts/BareB...
##
## This program is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License
## as published by the Free Software Foundation; either version 2
## of the License, or (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## Please read the full GNU GPL: http://www.gnu.org/copyleft/gpl.html
##
##### Variables #####
## Edit as needed…
# Path to sendmail
$mailProg = "/usr/sbin/sendmail -t";
# Your email address and be sure to leave the \ in front
# of the @ or else you'll get errors.. ;)
$toEmail = "questions\@atacards.com";
# Redirect them to this URL:
# This should be a pre-existing file with a thank you
# message or something similar..
$redirectURL = "http://www.atacards.com/contact/email_se...";
# Your time zone difference from GMT
$offSet = "-7";
# Military time 0 = off 1 = on
$milTime = 0;
##### Mailer ####
$fromName = param('nameField');
$formFirstname = param ('First_Name');
$formInitial = param ('Middle_Initial');
$formLastname = param ('Last_Name');
$fromEmail = param('Email_Address');
$formComments = param('Comments');
$formSubject = param ('Subject');
$formErrstart = ("<font color=\"red\"><b>* ");
$formErrend = ("</b></font>");
$formMissyntax = "(missing \@ or . symbol)";
# Create Order Status Page with Error Handling
unless(($formLastname)
&& ($formFirstname)
&& ($formComments)
&& (($fromEmail) && ($fromEmail =~ /.*\@.*/))
&& (($fromEmail) && ($fromEmail =~ /.*..*/))){
&headerFooter;
print qq|<p class="noindent">There are <font color="red"><b>missing</b></font> or
<font color="red"><b>incorrect fields</b></font> in your email.<br>\n|;
print qq|Please double check them on the <a href="#" onclick="window.blur();">
contact page</a> and re-click Finish..</p>\n|;
print qq|<table width="480" border="0" cellspacing="0" cellpadding="0">\n|;
print qq|<tr bgcolor="green"><td colspan="2"><p class="light">\n<b>
Your email shows the following information:</b></p></td></tr>|;
print qq| <tr bgcolor="#dcdcdc"><td><p class="smaller">|;
if (((!$formFirstname) && (!$formLastname)) ||
((!$formFirstname) || (!$formLastname))){
print qq|$formErrstart|;
}
print qq|Name: |;
if (((!$formFirstname) && (!$formLastname)) ||
((!$formFirstname) || (!$formLastname))){
print qq|$formErrend|;
}
print qq|</p></td><td><p class="invo">|;
if (!$formFirstname){
print qq|($formErrstart|;print qq|Name?|;print qq|$formErrend)|;
}
else {
print qq|$formFirstname |;
}
if (!$formInitial){
print qq||;
}
else{
print qq|$formInitial. |;
}
if (!$formLastname){
print qq|($formErrstart|;print qq|Last Name?|;print qq|$formErrend)|;
}
else {
print qq|$formLastname |;
}
print qq|</p></td></tr>\n|;
print qq| <tr><td><p class="smaller">|;
if (!$fromEmail){
print qq|$formErrstart|;print qq|Email Address:|;print qq|$formErrend|;
}
else {
print qq|Email Address:|;
}
if (($fromEmail) && (($fromEmail !~ /.*\@.*/) || ($fromEmail !~ /.*\..*/))){
print qq|$formErrstart|;
print qq|Email:|;
print qq|$formMissyntax|;
print qq|$formErrend|;
}
print qq|</p></td>\n|;
print qq| <td><p class="invo">|;
if (!$fromEmail){
print qq|($formErrstart|;print qq|Email Required|;print qq|$formErrend)|;
}
else {
print qq|$fromEmail|;
}
print qq|</p></td></tr>\n|;
print qq| <tr><td colspan="2"><p class="smaller">|;
if (!$FormComments){
print qq|$formErrstart|;print qq|Email Content:$formErrend|;
}
else {
print qq|Email Content:|;
}
print qq|</p>\n|;
print qq| <p class="smaller">|;
print qq|$formComments</p></td></tr>\n|;
print qq|<tr bgcolor="green"><td colspan="2"><p class="light"><b>|;
print qq|Please fix or make the entries shown in red on the contact page, <br>\n|;
print qq|You may then click the finish button again and
this window will show your email.</b></p>\n|;
print qq|</td></tr></table>\n\n|;
print @footer;
exit;
}
@months = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
@time = gmtime(time + (3600 * $offSet));
$newMinSec = sprintf("%02d:%02d",$time[1],$time[0]);
$newDay = sprintf("%02d",$time[3]);
$years = $time[5] + 1900;
if ($milTime) { $hours = sprintf("%02d",$time[2]); }
else {
if ($time[2] < 12) { if ($time[2] == 0) { $hours = 12; }
else { $hours = $time[2]; } $amPm = " AM"; }
else { if ($time[2] > 12) { $hours = $time[2] - 12; }
else { $hours = $time[2]; } $amPm = " PM"; }
}
$dateFormat = "$newDay/$months[$time[4]]/$years at $hours:$newMinSec$amPm";
$remoteAddress = $ENV{'REMOTE_ADDR'};
$remoteHost = $ENV{'REMOTE_HOST'};
@subnetNumbers = split (/\./, $remoteAddress);
$packedAddress = pack ("C4", @subnetNumbers);
($remoteHost) = gethostbyaddr ($packedAddress, 2);
# Start of Email back to ATAcards
open(MAIL, "|$mailProg") || die "Unable to open Mail Program.";
print MAIL "To: $toEmail\n";
print MAIL "From: \"$formFirstname $formLastname\" <$fromEmail>\n";
print MAIL "Subject: ATAcards WebEmail- $formSubject\n";
print MAIL "Date: $dateFormat.\n";
print MAIL "MIME-Version: 1.0\n";
print MAIL "Content-Type: text/html;";
print MAIL "charset=\"iso-8859-1\"\n";
print MAIL "Content-Transfer-Encoding: 8bit\n\n";
# HTML Part
print MAIL "<x-html><!x-stuff-for-pete base=\"\" src=\"\" id=\"0\"
charset=\"\"><!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n";
print MAIL "<HTML><HEAD>\n";
print MAIL "<META http-equiv=Content-Type content=\"text/html; charset=windows-1252\">\n";
print MAIL "<link href=\"http://www.atacards.com/styles/style.css..."
rel=\"stylesheet\" media=\"screen\">\n";
print MAIL "</HEAD>\n";
print MAIL "<BODY bgColor=#ffffff>\n";
print MAIL "<img src=\"http://www.atacards.com/images/ATAC_logo...";
print MAIL "<font color=\"blue\">\n";
print MAIL "<p class=\"noindent\">Name: $fromName<br>\n";
print MAIL "Email: $fromEmail</p>\n";
print MAIL "<p class=\"noindent\">$formComments</p>\n";
print MAIL "</font>\n";
print MAIL "<p> </p><p class=\"noindent\">End Transmission</p>\n";
print MAIL "</PRE></BODY></HTML>\n\n";
print MAIL "</x-html>\n";
close(MAIL);
# End of email to ATAcards
# _________________________________________________________
# End of Email
print "Location: $redirectURL\n\n";
exit;
sub headerFooter {
# ————————————————
open (FILE, "email-template.html")
|| die "Unable to open the Mailer Template for reading..";
@HTMLFile = <FILE>;
close(FILE);
for ($a = 0; $a < @HTMLFile; $a++)
{ if ($HTMLFile[$a] =~ /<!– mailer output will be here –>/) { $foundIt = 1; last; } }
unless($foundIt) { die "HTML comments not found in the Email Template.."; }
for ($i = 0; $i < $a; $i++) { push(@header, $HTMLFile[$i]); }
for ($i = $a; $i < @HTMLFile; $i++) { push(@footer, $HTMLFile[$i]); }
print "Content-type: text/html\n\n";
print @header;
}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>ATAcards.com Email Contact - Error</title>
<meta HTTP-EQUIV=" pragma" CONTENT="no-cache">
<meta NAME="copyright" content="© Copyright 2007 David S. Leverich, ATACards.com">
<meta NAME="author" content="ATACards.com, David Leverich">
<meta NAME="GENERATOR"
CONTENT="This page was created by custom ATAcards.com
Perlscript, creating each page dynamically.">
<link href="http://www.atacards.com/styles/style.css" rel="stylesheet" media="screen">
</head>
<body bgcolor="white">
<div align="center"><img src="http://www.atacards.com/images/ATAC_logo..."
alt="ATAcards.com - Your source for proffessional ATA Business Cards">
<h2 class="noindent">ATAcards.com Email Contact Error</h2>
<!– mailer output will be here –>
</div>
</body></html>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>ATACards.com Email Sent!</title>
<meta HTTP-EQUIV=" pragma" CONTENT="no-cache">
<meta NAME="copyright" content="© Copyright 2004 ATACards.com, David S. Leverich">
<meta NAME="author" content="ATACards.com, David Leverich">
<link href="http://www.atacards.com/styles/style.css" rel="stylesheet" media="screen">
</head>
<script LANGUAGE="JavaScript">
<!–
function closeit() {
window.close();
}
//–>
</script>
<body BGCOLOR="white" onload="window.focus(); window.setTimeout('closeit()', 8000);">
<div align="center">
<img src="http://www.atacards.com/images/ATAC_logo..."
alt="ATAcards.com - Your source for proffessional ATA Business Cards"><p> </p>
<table width="480" border="0" cellspacing="0" cellpadding="0">
<tr><td>
<h3>ATAcards - Thank you for your Email!</h3>
<p>Your Email has been sent to Mr. Leverich.</p>
<p>Feel free to select any of our areas to the left,
or view our costs & specifics or FAQ's on the chevron links above.</p>
<p> This window will close in a few seconds.</p>
<p></p>
<p>- David Leverich.</p>
</td></tr>
</div>
</body>
</html>
<input type="hidden" name="recipient" value="myemail@mydomain.com">
<input type="hidden" name="recipient" value="myemail@mydomain.com">
I guess my question is if anyone else is running a VPS and has configured a script for this. I understand I'll probably have to install something in my server to handle sending emails, probably cgi, and other stuff. I guess I'm just fishing for a good place to start if anyone has any suggestions.
Thanks in advance!