View Full Version : Mail problem
I have a PHP script that does the following:
mail ($recipient, $subject, $message, $extra);
It worked a few days ago and tonight I am not getting e-mails...
Anyone know what gives?
Morgan
PS: Yes, I have the variables filled appropriately...
Turns out I had a comment in the script and once removed, it began working again.
Can someone fill me in on how to put comments in a php script and have it work?
tbonekkt
12-11-03, 01:46 PM
// Single line commented
mail ($recipient, $subject, $message, $extra);
/*
Multiple
Lines
Commented
*/
Here is the script that failed<?php # script 2.2 - handle_order.php
$name = stripslashes($name);
$company = stripslashes($company);
$address1 = stripslashes($address1);
$address2 = stripslashes($address2);
$city = stripslashes($city);
$state = stripslashes($state);
$zip = stripslashes($zip);
$phone = stripslashes($phone);
$tray = stripslashes($tray);
# $recipient = "Morgan <teamtj@pars.net>;John DiCapo <dicapo@swbell.net>";
$recipient = "Morgan <teamtj@pars.net>";
$subject = "Cookie Order";
# $message = "Hello!\n\r\n\r$name has ordered the following:.\n\r\n\ralmondslice-$almondslice\n\rfigcookie-$figcookie\n\rgrahamcrackercup-$grahamcrackercup\n\rlemondrop-$lemondrop\n\rmondlebread-$mondlebread\n\rrussianteaball-$russianteaball\n\rsesameseedcookie-$sesameseedcookie\n\rtaytu-$taytu\n\rthumbprint-$thumbprint\n\rtriplechocolate-$triplechocolate\n\rweddingcookie-$weddingcookie\n\rvarietytray-$tray\n\r\n\rContact Information:\n\r\n\rName: $name\n\rCompany: $company\n\rAddress 1: $address1\n\rAddress 2: $address2\n\rCity: $city\n\rState: $state\n\rZip: $zip\n\rPhone: $phone";
$message = "Hello!\n\r\n\r$name has ordered the following:.\n\r\n\rVariety Tray - $tray\n\r\n\rContact Information:\n\r\n\rName: $name\n\rCompany: $company\n\rAddress 1: $address1\n\rAddress 2: $address2\n\rCity: $city\n\rState: $state\n\rZip: $zip\n\rPhone: $phone";
$extra = "From: CookieOrder\r\nReply-To: test@dicapofoods.com\r\n";
//echo($message);
mail ($recipient, $subject, $message, $extra);
?>
Here is the script that works <?php # script 2.2 - handle_order.php
$name = stripslashes($name);
$company = stripslashes($company);
$address1 = stripslashes($address1);
$address2 = stripslashes($address2);
$city = stripslashes($city);
$state = stripslashes($state);
$zip = stripslashes($zip);
$phone = stripslashes($phone);
$tray = stripslashes($tray);
$recipient = 'Morgan <teamtj@pars.net>;John DiCapo <dicapo@swbell.net>";';
$subject = "Cookie Order";
$message = "Hello!\n\r\n\r$name has ordered the following:.\n\r\n\rVariety Tray - $tray\n\r\n\rContact Information:\n\r\n\rName: $name\n\rCompany: $company\n\rAddress 1: $address1\n\rAddress 2: $address2\n\rCity: $city\n\rState: $state\n\rZip: $zip\n\rPhone: $phone";
$extra = "From: CookieOrder\r\nReply-To: test@dicapofoods.com\r\n";
//echo($message);
mail ($recipient, $subject, $message, $extra);
?>
I don't see a real difference...
I put single quotes around the e-mail addresses for $recipient and removed the comments, is all...
tbonekkt
12-11-03, 05:30 PM
I may be mistaken here, but I believe all commented lines need to have the "#" or "//" if not using the multiple line comment combination I posted above.
EDIT: corrected my double statement. :)
Those aren't multiple lines, it's just one REALLY long line that is commented out...
YvetteKuhns
12-11-03, 08:00 PM
That is a long comment statement. Yes, there should be "#" or "//" before AND after and they must match. In other words,
# comment # or // comment // . Syntax error!
HalfaBee
12-11-03, 08:52 PM
I beg to differ.
# and // don't need anything to end the comment except a newline
The other thing is that you are supposed to use a comma ',' to seperate the email addrs.
All they joys are the world are available in the manual.
http://us4.php.net/manual/en/language.basic-syntax.comments.php
YvetteKuhns
12-12-03, 11:42 AM
Oops! Thinking of <!-- --> for html, javascript, style sheets. I notice after I posted, but I lost the thread. Need sleep.
vBulletin v3.6.0, Copyright ©2000-2010, Jelsoft Enterprises Ltd.