The original files.
Form.php:
PHP Code:
<form action="<? echo $_SERVER['PHP_SELF']; ?>" method="POST">
<table width="100%">
<tr><td align="left" width="15%">Your Name:</td>
<td align="left" width="80%"><input type="text" name="name" size="30" value="<? echo $_POST['name']; ?>"></td></tr>
<tr><td align="left" width="15%">Your E-mail:</td>
<td align="left" width="80%"><input type="text" name="email" size="30" value="<? echo $_POST['email']; ?>"></td></tr>
<tr><td align="left" width="15%">Subject:</td>
<td align="left" width="80%"><input type="text" name="subject" size="30" value="<? echo $_POST['subject']; ?>"></td></tr>
<tr><td align="left" width="15%">Message:</td>
<td align="left" width="80%">
<p align="left"><textarea cols="63" rows="10" name="message"><? echo $_POST['message']; ?></textarea></p>
<p align="left"><input type="submit" name="submit" value="Send Mail">
<input type="reset" value="Reset">
</td>
</tr>
</table>
</form>
mail_functions.php:
PHP Code:
<?
function sendHTMLEmail($name, $email, $message, $subject, $recipient, $ip, $date, $time){
include("web2mail_config.php");
$recipient = "$yourname <$admin_email>";
$rand = md5(time());
$mime_boundary = "CJ Web2Mail V3.0_". $rand;
$text_version = "Submitted: $date - $time\nFrom: $name - $email\n\n\n$message\n\nIP: $ip\n\n\nPowered by CJ Web2Mail V3.0 © http://www.cj-design.com";
$html_version="<html>\n<head>\n<style>\nA:link {text-decoration: none; color: $alink_color;}\nA:visited {text-decoration: none; color: $vlink_color;}\nA:hover {font-style: normal; color: $hlink_color; text-decoration: underline;}\nBODY{font-family: $html_font; font-size: $html_font_size;}TD {font-family: $html_font; color: #000000; font-size: $html_font_size;}\n</style>\n</head>\n<body>\n\n<table border=\"0\" cellpadding=\"6\" cellspacing=\"0\" width=\"100%\">\n<tr>\n <td nowrap width=\"1%\">\n<b>Submitted</b>\n</td>\n<td width=\"99%\">$date - $time</td>\n</tr>\n<tr>\n<td nowrap width=\"1%\">\n<b>From</b></td>\n<td width=\"99%\">$name - <A HREF=\"mailto:$email\">$email</A></td>\n</tr>\n<tr>\n<td nowrap width=\"1%\" valign=\"top\">\n<b>Message</b></td>\n<td width=\"99%\">".nl2br($message)."</td>\n</tr>\n<tr>\n<td nowrap width=\"1%\"><b><small>IP Address</small></b></td>\n<td width=\"99%\"><small>$ip</small></td>\n</tr>\n</table><br>\n<br>\n<div align=\"right\"><i>Powered by <A HREF=\"http://www.cj-design.com\">CJ Web2Mail V3.0</A></i></div></body></html>";
$headers = "From: $name <$email>\r\n";
$headers .= "Reply-to: $email\r\n";
$headers .= "Return-Path: $email\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: multipart/alternative; charset=\"iso-8859-1\"; boundary=\"$mime_boundary\";\r\n\r\n"; // added ; before boundary
$headers .= "This is a multi-part message in MIME format.\r\n\r\n";
$msg .= "--$mime_boundary\r\n";
$msg .= "Content-Type: text/plain; charset=\"iso-8859-1\"\r\n"; // deleted boundary
$msg .= "Content-Transfer-Encoding: 8bit\r\n\r\n";
$msg .= $text_version."\r\n\r\n";
$msg .= "--$mime_boundary\r\n";
$msg .= "Content-Type: text/html; charset=\"iso-8859-1\"\r\n";
$msg .= "Content-Transfer-Encoding: 8bit\r\n\r\n";
$msg .= $html_version."\r\n\r\n";
$msg .= "--$mime_boundary--\r\n\r\n\r\n";
return mail($recipient, $subject, $msg, $headers);
}
function sendHTMLEmailAuto($name, $email, $subject){
include("web2mail_config.php");
$recipient = "$name <$email>";
$rand = md5(time());
$mime_boundary = "CJ Web2Mail V3.0_". $rand;
$sub = "$auto_subject to $name";
$text_version = "$name, thank you for emailing $your_website.\n\nWe will get back to you soon concerning '$subject'.\n\nKind Regards\n$yourname\n\n\nNote: This is an automated response, please do not reply to this\n\n\nPowered by CJ Web2Mail V3.0 © http://www.cj-design.com";
$html_version = "<html>\n<head>\n<style>\nA:link {text-decoration: none; color: $alink_color;}\nA:visited {text-decoration: none; color: $vlink_color;}\nA:hover {font-style: normal; color: $hlink_color; text-decoration: underline;}\nBODY{font-family: $html_font; font-size: $html_font_size;}TD {font-family: $html_font; color: #000000; font-size: $html_font_size;}\n</style>\n</head>\n<body>\n\n<B>$name</B>, thank you for emailing $your_website.\n\n<br><br>We will get back to you soon concerning '<I><B>$subject</B></I>'.\n<br><br>\nKind Regards<br>\n$yourname<br>\n<br>\n<br>\n<small>Note: This is an automated response, please do not reply to this</small><br>\n<br><div align=\"right\"><i>Powered by <A HREF=\"http://www.cj-design.com\">CJ Web2Mail V3.0</A></i></div>";
$headers = "From: $your_website <$admin_email>\r\n";
$headers .= "Reply-to: $admin_email\r\n";
$headers .= "Return-Path: $admin_email\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: multipart/alternative; charset=\"iso-8859-1\"; boundary=\"$mime_boundary\";\r\n\r\n"; // added ; before boundary
$headers .= "This is a multi-part message in MIME format.\r\n\r\n";
$msg .= "--$mime_boundary\r\n";
$msg .= "Content-Type: text/plain; charset=\"iso-8859-1\"\r\n"; // deleted boundary
$msg .= "Content-Transfer-Encoding: 8bit\r\n\r\n";
$msg .= $text_version."\r\n\r\n";
$msg .= "--$mime_boundary\r\n";
$msg .= "Content-Type: text/html; charset=\"iso-8859-1\"\r\n";
$msg .= "Content-Transfer-Encoding: 8bit\r\n\r\n";
$msg .= $html_version."\r\n\r\n";
$msg .= "--$mime_boundary--\r\n\r\n\r\n";
$msg = stripslashes($msg);
mail ($recipient, $sub, $msg, $headers);
}
function sendTextEmailAuto($name, $email, $subject){
include("web2mail_config.php");
$recipient = "$name <$email>";
$sub = "$auto_subject to $name";
$msg = "$name, thank you for emailing $your_website.\n\nWe will get back to you soon concerning '$subject'.\n\nKind Regards\n$yourname\n\n\nNote: This is an automated response, please do not reply to this\n\n\nPowered by CJ Web2Mail V3.0 © http://www.cj-design.com";
$headers = "From: $your_website <$admin_email>\r\nReply-To: $admin_email\r\n";
$msg = stripslashes($msg);
mail ($recipient, $sub, $msg, $headers);
}
?>
thankyou.php:
PHP Code:
<?
if($sent){
?>
Thank you <? echo $name; ?>, we will contact you shortly.<br><br>
Your message:<br><br>
<table border="0" cellpadding="10" cellspacing="0" width="450">
<tr>
<td width="440"><small><? echo nl2br($message); ?></small></td>
</tr>
</table>
<br><br>
<?
if($show_ip == "yes"){
echo "<small>We have captured your IP (<I>$ip</I>) for security reasons</small>";
}
}
else{
print "$name, we could not send your message at this time, please try again later";
}
?>
web2mail.php:
PHP Code:
<!-- You can insert a stylesheet here -->
<?
include "web2mail_config.php";
$path = __FILE__;
$path = preg_replace( "'\\\web2mail\.php'", "", $path);
$path = preg_replace( "'/web2mail\.php'", "", $path);
$send = false;
if(isset($_POST['submit'])){
$date = date("l d F Y");
$time = date("g:i:s a");
$ermsg = "";
$send = true;
$ip = $_SERVER['REMOTE_ADDR'];
$name = cleanUp($_POST['name']);
$email = cleanUp($_POST['email']);
$message = $_POST['message'];
$subject = cleanUp($_POST['subject']);
$emailvalid = is_valid_email($email);
if (!isset($name) || $name == ""){
$emsg = "<li>Please enter your name"; $send = false;
}
if (!isset($email) || $email == "" || $emailvalid == 1){
$emsg .= "<li>Your email address is missing or incorrect"; $send = false;
}
if (!isset($subject) || $subject == ""){
$emsg .= "<li>Please enter a subject"; $send = false;
}
if (!isset($message) || $message == ""){
$emsg .= "<li>Your message is blank"; $send = false;
}
if($send){
$sent = false;
include("mail_functions.php");
$message = strip_tags($message);
$message = stripslashes($message);
$subject = stripslashes($subject);
if($multipart_emails == "yes"){
if(sendHTMLEmail($name, $email, $message, $subject, $recipient, $ip, $date, $time)){
$sent = true;
}
}
else{
$recipient = "$yourname <$admin_email>";
$headers = "From: $name <$email>\r\nReply-To: $email\r\n";
$msg = "Submitted: $date - $time\nFrom: $name - $email\n\n\n$message\n\nIP: $ip\n\n\nPowered by CJ Web2Mail V3.0 © http://www.cj-design.com";
if(mail ($recipient, $subject, $msg, $headers)){
$sent = true;
}
}
if($sent){
if($auto_responder == "yes"){
if($multipart_emails == "yes"){
sendHTMLEmailAuto($name, $email, $subject);
}
else{
sendTextEmailAuto($name, $email, $subject);
}
}
if($default_thank_msg == "yes"){
include($path."/thankyou.php");
}
else{
header("Location: $thankyou_message_url");
}
}
else{
include($path."/thankyou.php");
}
}
}
if(!$send){
if(strlen($emsg) > 0 && $error_messages == "yes"){
echo "Your submission had the following errors:<br><br><FONT COLOR=\"red\">$emsg</FONT><br><br>";
}
include($path."/form.php");
}
function cleanUp($field)
{
//Remove line feeds
$ret = str_replace("\r", "", $field);
$ret = str_replace("\n", "", $ret);
// Remove injected headers
$find = array("/bcc\:/i",
"/Content\-Type\:/i",
"/Mime\-Type\:/i",
"/cc\:/i",
"/to\:/i");
$ret = preg_replace($find, "", $ret);
return $ret;
}
function is_valid_email($sender_mail) {
if(ereg("([[:alnum:]\.\-]+)(\@[[:alnum:]\.\-]+\.+)", $sender_mail)) {
return 0;
}
else{
return 1;
}
}
?>
web2mail_config.php:
PHP Code:
<?
$yourname = "Your Name";
$your_website = "Your Site Name";
$your_webaddress = "http://www.yoursite.com";
$admin_email = "yourname@youremail.com";
$show_ip = "yes";
$auto_responder = "yes";
$auto_subject = "Auto Responder";
$error_messages = "yes";
$multipart_emails = "yes";
$html_font = "verdana";
$html_font_size = "10pt";
$alink_color = "#11116E";
$vlink_color = "#11116E";
$hlink_color = "#000000";
$default_thank_msg = "yes";
$thankyou_message_url = "";
?>
Bookmarks