Hey guys, I am designing a "free"
email script, but I can't figure
out this error, plus would like to know
if anybody can spot any "major" flaws:
// Above here is copyright crap
$ses = "";
// make it so the quote marks are empty
// if you want the script TURNED OFF;
// i.e. $ses = ""; for OFF or $ses = "1"; for ON
$forward = "http://GamerDesigns.com/gdSES/";
// Set to your URL if the
// script IS TURNED OFF
// DO NOT FORGET THE ENDING SLASH
$success = "$forward";
// Set to the URL to a "Thank you!" page; if not
// just put "$forward"; instead of "http://url-here";
// i.e. <!-- m --><a class="postlink" href="http://yoursite.com/thankyou.htm">http://yoursite.com/thankyou.htm</a><!-- m --> or $forward
$site_name = "Your Site Name Here";
// Set to the name of your site
$email_to = "[email protected]";
// Put your email address here
// It'll also be used as the one
// the "emails" will appear from.
$cc_email = "";
// Add an email here if you wish
// for a copy to be sent to another
// email address; leave empty if not.
$subject = "Email Contact from gdSES Contact Form";
// Edit with the subject line you want
// it to use when it sends the email to
// you from the contact form.
/****************************
NO USER-EDITABLE OPTIONS PAST
HERE. PLEASE DO NOT EDIT UNLESS
YOU KNOW WHAT YOU ARE DOING!
****************************/
if (!$ses) {
echo "Sorry but the contact form is currently OFFLINE!<Br>";
echo "You will now be forwarded; click <A href=http://www.htmlforums.com/archive/index.php/\"$forward\">here</a> ";
echo "if you do not wish to wait";
echo "<meta http-equiv=\"Refresh\" content=\"2; url=$forward\">";
// The above is saying "Script is off -- go away to home page"
} else {
// Saying "hey let's make it work"
$name = $HTTP_POST_VARS['name'];
$email_from = $HTTP_POST_VARS['email_from'];
$message = $HTTP_POST_VARS['message'];
if (empty($name)) $error[]="You did not fill out the Name Field; please correct this!";
if (empty($email)) $error[]="You did not fill out the Email Field; please correct this!";
if (empty($message)) $error[]="You did not fill out the Message Field; please correct this!";
if (isset($error)==false)
{
$copy_to = "$cc_email";// Who to copy email to
$email_from = "$email_from";// From the email addie
$subject = "$subject";// Subject line here
$msgtxt = "The following message was sent from the gdSES Contact Form:\n\n$message\n\nName of Contact: $name\nEmail:$email_from";
mail($email_to,$copy_to,$subject,$message);
echo "Thank you for sending an email to $site_name!<br>";
echo "You are now being forward; click <a href=http://www.htmlforums.com/archive/index.php/\"$success\">here</a> ";
echo "if you do not wish to wait";
echo "<meta http-equiv=\"Refresh\" content=\"2; url=$success\">";
echo "<br><Br><Br>";
echo "This script was made by <a href=http://www.htmlforums.com/archive/index.php/\"http://GamerDesigns.com\" target=\"_blank\">Gamer Designs</a><BR>";
echo "gdSES is free for personal use -- please check the site out for more info!";
// Basicly saying "Hey, either wait to forward or click to go there
} else {
echo "Cannot send message!";
}
}
?>
It keeps coming out as 'CANNOT SEND MESSAGE'
<!-- m --><a class="postlink" href="http://gamerdesigns.com/gdSES/">http://gamerdesigns.com/gdSES/</a><!-- m --> > contact page
Any advise?$name = $HTTP_POST_VARS['name'];
$email_from = $HTTP_POST_VARS['email_from'];
$message = $HTTP_POST_VARS['message'];
if (empty($name)) $error[]="You did not fill out the Name Field; please correct this!";
if (empty($email)) $error[]="You did not fill out the Email Field; please correct this!";
if (empty($message)) $error[]="You did not fill out the Message Field; please correct this!";
You check if $email is empty, but i guess that should be $email_fromalso you are checking for a variable, not an array
if (!is_array($error))
{
and this is wrong
mail($email_to,$copy_to,$subject,$message);
you cannot have $copy_to in there like that. $message will not be sent as $message is in the header spot. if you wnat to send a CC or a BCC then you have to add it to the header.
<!-- m --><a class="postlink" href="http://www.php.net/manual/en/function.mail.php">http://www.php.net/manual/en/function.mail.php</a><!-- m -->
email script, but I can't figure
out this error, plus would like to know
if anybody can spot any "major" flaws:
// Above here is copyright crap
$ses = "";
// make it so the quote marks are empty
// if you want the script TURNED OFF;
// i.e. $ses = ""; for OFF or $ses = "1"; for ON
$forward = "http://GamerDesigns.com/gdSES/";
// Set to your URL if the
// script IS TURNED OFF
// DO NOT FORGET THE ENDING SLASH
$success = "$forward";
// Set to the URL to a "Thank you!" page; if not
// just put "$forward"; instead of "http://url-here";
// i.e. <!-- m --><a class="postlink" href="http://yoursite.com/thankyou.htm">http://yoursite.com/thankyou.htm</a><!-- m --> or $forward
$site_name = "Your Site Name Here";
// Set to the name of your site
$email_to = "[email protected]";
// Put your email address here
// It'll also be used as the one
// the "emails" will appear from.
$cc_email = "";
// Add an email here if you wish
// for a copy to be sent to another
// email address; leave empty if not.
$subject = "Email Contact from gdSES Contact Form";
// Edit with the subject line you want
// it to use when it sends the email to
// you from the contact form.
/****************************
NO USER-EDITABLE OPTIONS PAST
HERE. PLEASE DO NOT EDIT UNLESS
YOU KNOW WHAT YOU ARE DOING!
****************************/
if (!$ses) {
echo "Sorry but the contact form is currently OFFLINE!<Br>";
echo "You will now be forwarded; click <A href=http://www.htmlforums.com/archive/index.php/\"$forward\">here</a> ";
echo "if you do not wish to wait";
echo "<meta http-equiv=\"Refresh\" content=\"2; url=$forward\">";
// The above is saying "Script is off -- go away to home page"
} else {
// Saying "hey let's make it work"
$name = $HTTP_POST_VARS['name'];
$email_from = $HTTP_POST_VARS['email_from'];
$message = $HTTP_POST_VARS['message'];
if (empty($name)) $error[]="You did not fill out the Name Field; please correct this!";
if (empty($email)) $error[]="You did not fill out the Email Field; please correct this!";
if (empty($message)) $error[]="You did not fill out the Message Field; please correct this!";
if (isset($error)==false)
{
$copy_to = "$cc_email";// Who to copy email to
$email_from = "$email_from";// From the email addie
$subject = "$subject";// Subject line here
$msgtxt = "The following message was sent from the gdSES Contact Form:\n\n$message\n\nName of Contact: $name\nEmail:$email_from";
mail($email_to,$copy_to,$subject,$message);
echo "Thank you for sending an email to $site_name!<br>";
echo "You are now being forward; click <a href=http://www.htmlforums.com/archive/index.php/\"$success\">here</a> ";
echo "if you do not wish to wait";
echo "<meta http-equiv=\"Refresh\" content=\"2; url=$success\">";
echo "<br><Br><Br>";
echo "This script was made by <a href=http://www.htmlforums.com/archive/index.php/\"http://GamerDesigns.com\" target=\"_blank\">Gamer Designs</a><BR>";
echo "gdSES is free for personal use -- please check the site out for more info!";
// Basicly saying "Hey, either wait to forward or click to go there
} else {
echo "Cannot send message!";
}
}
?>
It keeps coming out as 'CANNOT SEND MESSAGE'
<!-- m --><a class="postlink" href="http://gamerdesigns.com/gdSES/">http://gamerdesigns.com/gdSES/</a><!-- m --> > contact page
Any advise?$name = $HTTP_POST_VARS['name'];
$email_from = $HTTP_POST_VARS['email_from'];
$message = $HTTP_POST_VARS['message'];
if (empty($name)) $error[]="You did not fill out the Name Field; please correct this!";
if (empty($email)) $error[]="You did not fill out the Email Field; please correct this!";
if (empty($message)) $error[]="You did not fill out the Message Field; please correct this!";
You check if $email is empty, but i guess that should be $email_fromalso you are checking for a variable, not an array
if (!is_array($error))
{
and this is wrong
mail($email_to,$copy_to,$subject,$message);
you cannot have $copy_to in there like that. $message will not be sent as $message is in the header spot. if you wnat to send a CC or a BCC then you have to add it to the header.
<!-- m --><a class="postlink" href="http://www.php.net/manual/en/function.mail.php">http://www.php.net/manual/en/function.mail.php</a><!-- m -->