nkokhi
05-07-2008, 07:58 AM
HI
Im having some problems with PHP autoresponder functions.
1. I need to set the “From” header that will appear on Sender’s “From: header”
2. I need to attached / include the sent message with the confirmation.
PHP is new to my world and I need some help. The current script is working but the Autoresponder message header shows: me@www6.cpt341.host-h.net and I need to change this to ie. Me@mydomain.com
With the inclusion of sent message; Im totally blank.
Herewith the form code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Contact us</title>
<style type="text/css">
<!--
td.form { color: #606060; font-family: "Arial", "Helvetica", "sans-serif"; font-size: 12; }
td.main { color: #000000; font-family: "Arial", "Helvetica", "sans-serif"; font-size: 12; }
font.form_check { color: red; }
input { font-family: "Arial", "Helvetica", "sans-serif"; color:#606060; font-size: 12px; }
textarea { font-family: "Arial", "Helvetica", "sans-serif"; color:#606060; font-size: 12px; }
.style1 {
font-family: Geneva, Arial, Helvetica, sans-serif;
font-size: 11;
}
-->
</style>
</head>
<body>
<!-- Put headers above here -->
<span class="style1">
<?php
/*
*/
//Here are the things you need to change
//Your email address
$emaddress = "me@me.co.za";
//This is the colour that will go round the box if the user forgets to fill it in in HEX
$embordercolor = "#ff0000";
//The title of your website
$sitetitle = "me";
//HTML E-mail. If you can recieve HTML e-mail you should set this to 1
//0 is off and 1 is on. Defult is off. You may want to change the $autobody variable in the code
$htmlemail = 1;
//Auto-responder. This will send a thank you message to the user. Note : Some people may find this annoying
//0 is off and 1 is on. Defult is off. You may want to change the $autobody variable in the code
$autoresponder = 1;
//Do not change anything below here
/*----------------------------------------------------------------------------------*/
$validstring = '^([._a-z0-9-]+[._a-z0-9-]*)@(([a-z0-9-]+\.)*([a-z0-9-]+)(\.[a-z]{2,3}))$';
if (!eregi($validstring,$email)&&$email) {
$emailcorrect = 0;
}
else {
$emailcorrect = 1;
}
if($email&&$message&&$subject&&$name&&$emailcorrect) {
if($autoresponder)
{
$autobody = "Thank You, $name for sending me an e-mail through my website.
From
$sitetitle
";
$autosubject = "Thank you from $sitetitle";
mail($email, $autosubject, $autobody, "From: $sitetitle");
}
$headers = "From: " . trim($name) . "\n";
if($htmlemail)
{
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: $name <$email>\r\n";
$headers .= "Reply-To: $name <$email>\r\n";
$body = "E-mail is from " . $name . " at " . $email .
".<br><br>This is the message sent:<br><br>" . "Subject: - " . $subject ."<br><br>"
. $message . ".";
}
else
{
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: $name <$email>\r\n";
$headers .= "Reply-To: $name <$email>\r\n";
$body = "E-mail is from " . $name . " at " . $email." - Company name: " .$company ." - Membership number: " . $Membership_no
."<br><br>". "Subject: - " . $subject ."<br><br>"
. $message . ".";
}
else
{
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/plain; charset=iso-8859-1\r\n";
$headers .= "From: $name <$email>\r\n";
$headers .= "Reply-To: $name <$email>\r\n";
$body = "E-mail is from $name at $email
Company name: $company
Membership number: $Membership_no.
Subject: $subject
$Message \n-----------------------------------------------------------------------\n $message \n-----------------------------------------------------------------------\n";
}
$thesubject = "MEMBERSHIP Website Equiry: $subject";
if(mail($emaddress, $thesubject, $body, $headers)) {
echo "<br><br>Your e-mail was sent successfully. Thank you for the message " . $name . ".";
}
else {
echo "Sorry, $name, your e-mail was not sent successfully please try again<br><br>";
echo "<form name=\"theform\" method=\"get\" action=\"contact_fundi.php\">";
echo "Your name:<br><input name=\"name\" type=\"text\" value=\"$name\"><br>";
echo "Your e-mail:<br><input name=\"email\" type=\"text\" value=\"$email\"><br>";
echo "Your company:<br><input name=\"company\" type=\"text\" value=\"$company\"><br>";
echo "Membership no.:<br><input name=\"Membership_no\" type=\"text\" value=\"$Membership_no\"><br>";
echo "Subject:<br><input name=\"subject\" type=\"text\" value=\"$subject\"><br>";
echo "Message:<br><textarea name=\"message\" rows=4 cols=30>$message</textarea>";
echo "<br><input type=\"submit\" value=\"Send\" class=\"submit\"></form>";
}
}
if ((!$emailcorrect||!$email||!$message||!$subject||!$name)&&!(!$email&&!$message&&!$subject&&!$name)) {
echo "The Following errors have occurred.<br>";
echo "<ul>";
if (!$emailcorrect) {
echo "<li> Your e-mail address is not valid.";
}
if (!$email||!$message||!$subject||!$name) {
echo "<li> You have forgotten to fill in a detail.";
}
echo "</ul>Please correct the error(s) and resubmit the form";
echo "<style>";
if (!$email||!$emailcorrect) {
echo ".email {border-color:" . $embordercolor . ";}";
}
if (!$name) {
echo ".name {border-color:" . $embordercolor . ";}";
}
if (!$message) {
echo ".message {border-color:" . $embordercolor . ";}";
}
if (!$subject) {
echo ".subject {border-color:" . $embordercolor . ";}";
}
echo "</style>";
echo "<form name=\"theform\" method=\"get\" action=\"contact_fundi.php\">";
echo "Your name:<br><input name=\"name\" type=\"text\" value=\"$name\" class=\"name\"><br>";
echo "Your e-mail:<br><input name=\"email\" type=\"text\" value=\"$email\" class=\"email\"><br>";
echo "Your company:<br><input name=\"company\" type=\"text\" value=\"$company\"><br>";
echo "Membership no.:<br><input name=\"Membership_no\" type=\"text\" value=\"$Membership_no\"><br>";
echo "Subject:<br><input name=\"subject\" type=\"text\" value=\"$subject\" class=\"subject\"><br>";
echo "Message:<br><textarea name=\"message\" rows=4 cols=30 class=\"message\">$message</textarea>";
echo "<br><input type=\"submit\" value=\"Send\" class=\"submit\"></form>";
}
if(!$email&&!$message&&!$subject&&!$name) {
echo "<form name=\"theform\" method=\"get\" action=\"contact_fundi.php\">";
echo "Your name:</b><br><input name=\"name\" type=\"text\" value=\"$name\"><br>";
echo "Your e-mail:</b><br><input name=\"email\" type=\"text\" value=\"$email\"><br>";
echo "Your company:<br><input name=\"company\" type=\"text\" value=\"$company\"><br>";
echo "Membership no.:<br><input name=\"Membership_no\" type=\"text\" value=\"$Membership_no\"><br>";
echo "Subject:</b><br><input name=\"subject\" type=\"text\" value=\"$subject\"><br>";
echo "Message:</b><br><textarea name=\"message\" rows=4 cols=30>$message</textarea>";
echo "<br><input type=\"submit\" value=\"Send\" class=\"submit\"></form>";
}
?>
<!-- Put footers below here -->
</body>
</html>
Im having some problems with PHP autoresponder functions.
1. I need to set the “From” header that will appear on Sender’s “From: header”
2. I need to attached / include the sent message with the confirmation.
PHP is new to my world and I need some help. The current script is working but the Autoresponder message header shows: me@www6.cpt341.host-h.net and I need to change this to ie. Me@mydomain.com
With the inclusion of sent message; Im totally blank.
Herewith the form code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Contact us</title>
<style type="text/css">
<!--
td.form { color: #606060; font-family: "Arial", "Helvetica", "sans-serif"; font-size: 12; }
td.main { color: #000000; font-family: "Arial", "Helvetica", "sans-serif"; font-size: 12; }
font.form_check { color: red; }
input { font-family: "Arial", "Helvetica", "sans-serif"; color:#606060; font-size: 12px; }
textarea { font-family: "Arial", "Helvetica", "sans-serif"; color:#606060; font-size: 12px; }
.style1 {
font-family: Geneva, Arial, Helvetica, sans-serif;
font-size: 11;
}
-->
</style>
</head>
<body>
<!-- Put headers above here -->
<span class="style1">
<?php
/*
*/
//Here are the things you need to change
//Your email address
$emaddress = "me@me.co.za";
//This is the colour that will go round the box if the user forgets to fill it in in HEX
$embordercolor = "#ff0000";
//The title of your website
$sitetitle = "me";
//HTML E-mail. If you can recieve HTML e-mail you should set this to 1
//0 is off and 1 is on. Defult is off. You may want to change the $autobody variable in the code
$htmlemail = 1;
//Auto-responder. This will send a thank you message to the user. Note : Some people may find this annoying
//0 is off and 1 is on. Defult is off. You may want to change the $autobody variable in the code
$autoresponder = 1;
//Do not change anything below here
/*----------------------------------------------------------------------------------*/
$validstring = '^([._a-z0-9-]+[._a-z0-9-]*)@(([a-z0-9-]+\.)*([a-z0-9-]+)(\.[a-z]{2,3}))$';
if (!eregi($validstring,$email)&&$email) {
$emailcorrect = 0;
}
else {
$emailcorrect = 1;
}
if($email&&$message&&$subject&&$name&&$emailcorrect) {
if($autoresponder)
{
$autobody = "Thank You, $name for sending me an e-mail through my website.
From
$sitetitle
";
$autosubject = "Thank you from $sitetitle";
mail($email, $autosubject, $autobody, "From: $sitetitle");
}
$headers = "From: " . trim($name) . "\n";
if($htmlemail)
{
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: $name <$email>\r\n";
$headers .= "Reply-To: $name <$email>\r\n";
$body = "E-mail is from " . $name . " at " . $email .
".<br><br>This is the message sent:<br><br>" . "Subject: - " . $subject ."<br><br>"
. $message . ".";
}
else
{
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: $name <$email>\r\n";
$headers .= "Reply-To: $name <$email>\r\n";
$body = "E-mail is from " . $name . " at " . $email." - Company name: " .$company ." - Membership number: " . $Membership_no
."<br><br>". "Subject: - " . $subject ."<br><br>"
. $message . ".";
}
else
{
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/plain; charset=iso-8859-1\r\n";
$headers .= "From: $name <$email>\r\n";
$headers .= "Reply-To: $name <$email>\r\n";
$body = "E-mail is from $name at $email
Company name: $company
Membership number: $Membership_no.
Subject: $subject
$Message \n-----------------------------------------------------------------------\n $message \n-----------------------------------------------------------------------\n";
}
$thesubject = "MEMBERSHIP Website Equiry: $subject";
if(mail($emaddress, $thesubject, $body, $headers)) {
echo "<br><br>Your e-mail was sent successfully. Thank you for the message " . $name . ".";
}
else {
echo "Sorry, $name, your e-mail was not sent successfully please try again<br><br>";
echo "<form name=\"theform\" method=\"get\" action=\"contact_fundi.php\">";
echo "Your name:<br><input name=\"name\" type=\"text\" value=\"$name\"><br>";
echo "Your e-mail:<br><input name=\"email\" type=\"text\" value=\"$email\"><br>";
echo "Your company:<br><input name=\"company\" type=\"text\" value=\"$company\"><br>";
echo "Membership no.:<br><input name=\"Membership_no\" type=\"text\" value=\"$Membership_no\"><br>";
echo "Subject:<br><input name=\"subject\" type=\"text\" value=\"$subject\"><br>";
echo "Message:<br><textarea name=\"message\" rows=4 cols=30>$message</textarea>";
echo "<br><input type=\"submit\" value=\"Send\" class=\"submit\"></form>";
}
}
if ((!$emailcorrect||!$email||!$message||!$subject||!$name)&&!(!$email&&!$message&&!$subject&&!$name)) {
echo "The Following errors have occurred.<br>";
echo "<ul>";
if (!$emailcorrect) {
echo "<li> Your e-mail address is not valid.";
}
if (!$email||!$message||!$subject||!$name) {
echo "<li> You have forgotten to fill in a detail.";
}
echo "</ul>Please correct the error(s) and resubmit the form";
echo "<style>";
if (!$email||!$emailcorrect) {
echo ".email {border-color:" . $embordercolor . ";}";
}
if (!$name) {
echo ".name {border-color:" . $embordercolor . ";}";
}
if (!$message) {
echo ".message {border-color:" . $embordercolor . ";}";
}
if (!$subject) {
echo ".subject {border-color:" . $embordercolor . ";}";
}
echo "</style>";
echo "<form name=\"theform\" method=\"get\" action=\"contact_fundi.php\">";
echo "Your name:<br><input name=\"name\" type=\"text\" value=\"$name\" class=\"name\"><br>";
echo "Your e-mail:<br><input name=\"email\" type=\"text\" value=\"$email\" class=\"email\"><br>";
echo "Your company:<br><input name=\"company\" type=\"text\" value=\"$company\"><br>";
echo "Membership no.:<br><input name=\"Membership_no\" type=\"text\" value=\"$Membership_no\"><br>";
echo "Subject:<br><input name=\"subject\" type=\"text\" value=\"$subject\" class=\"subject\"><br>";
echo "Message:<br><textarea name=\"message\" rows=4 cols=30 class=\"message\">$message</textarea>";
echo "<br><input type=\"submit\" value=\"Send\" class=\"submit\"></form>";
}
if(!$email&&!$message&&!$subject&&!$name) {
echo "<form name=\"theform\" method=\"get\" action=\"contact_fundi.php\">";
echo "Your name:</b><br><input name=\"name\" type=\"text\" value=\"$name\"><br>";
echo "Your e-mail:</b><br><input name=\"email\" type=\"text\" value=\"$email\"><br>";
echo "Your company:<br><input name=\"company\" type=\"text\" value=\"$company\"><br>";
echo "Membership no.:<br><input name=\"Membership_no\" type=\"text\" value=\"$Membership_no\"><br>";
echo "Subject:</b><br><input name=\"subject\" type=\"text\" value=\"$subject\"><br>";
echo "Message:</b><br><textarea name=\"message\" rows=4 cols=30>$message</textarea>";
echo "<br><input type=\"submit\" value=\"Send\" class=\"submit\"></form>";
}
?>
<!-- Put footers below here -->
</body>
</html>