Email Syntax Error
Date: 12/02/05
(PHP Community) Keywords: no keywords
Hello - I have a email script I have used for a long time and one numbnut is complaining about a syntax error in the email header. I can;t debug this because when email comes to me there is no syntax error. Besides the error notice, he still gets the full email.
Maybe one of you guys can see the error in the code. Names have been changed to protect the numbnuts.
Error
UNEXPECTED_DATA_AFTER_ADDRESS@.SYNTAX-ERROR.:
Code
if($_POST[client]){
$Phorm_msg = "Client:\n\n";
foreach($_POST[client] as $val)
{
$Phorm_msg = $Phorm_msg."$val\n";
}
$Phorm_msg = $Phorm_msg."\n\n";
}// end test
if($_POST[contact]){
$Phorm_msg = $Phorm_msg."Contact:\n\n";
foreach($_POST[contact] as $val)
{
$Phorm_msg = $Phorm_msg."$val\n";
}
$Phorm_msg = $Phorm_msg."\n\n";
}// end test
if($_POST[can]){
$Phorm_msg = $Phorm_msg."Client can:\n\n";
foreach($_POST[can] as $val)
{
$Phorm_msg = $Phorm_msg."$val\n";
}
$Phorm_msg = $Phorm_msg."\n\n";
}// end test
if($_POST[cant]){
$Phorm_msg = $Phorm_msg."Client can not:\n\n";
foreach($_POST[cant] as $val)
{
$Phorm_msg = $Phorm_msg."$val\n";
}
$Phorm_msg = $Phorm_msg."\n\n";
}// end test
if($_POST[hourly]){
$Phorm_msg = $Phorm_msg."Hourly:\n\n";
foreach($_POST[hourly] as $val)
{
$Phorm_msg = $Phorm_msg."$val\n";
}
$Phorm_msg = $Phorm_msg."\n\n";
}// end test
if($_POST[comments]){
$Phorm_msg = $Phorm_msg."Comments:\n\n";
foreach($_POST[comments] as $val)
{
$Phorm_msg = $Phorm_msg."$val\n";
}
}// end test
$Phorm_err = "error.html";
$Phorm_ok = "thank_you.html";
$Phorm_subj = "Website Inquiry";
$Phorm_headSend = "From: name@email.com \n";
$Phorm_headSend .= "Reply-To: $_POST[contact][8]\n\n";
$zip = trim($_POST[contact][5]);
$zip2 = trim(substr($_POST[contact][5], 0, 2));
$zip3 = trim(substr($_POST[contact][5], 0, 3));
$NJJim = array(
'08201', '08205', '08401', '08404', '08405', '08203', '08310', '08213', '08317', '08215', '08234', '08217', '08319', '08326',
'08220', '08221', '08403', '08402', '08330', '08340', '08341', '08342', '08346', '08225', '08231', '08232', '08240', '08241',
'08350', '08244', '08406', '08010', '08011', '08505', '08015', '08016', '08019', '08022', '08511', '08515', '08518', '08036',
'08041', '08042', '08048', '08052', '08053', '08055', '08057', '08060', '08054', '08224', '08064', '08065', '08068', '08073',
'08075', '08076', '08077', '08554', '08640', '08641', '08088', '08046', '08562', '08004', '08106', '08007', '08031', '08099',
'08009', '08012', '08101', '08102', '08103', '08104', '08105', '08018', '08002', '08003', '08034', '08021', '08108', '08026',
'08029', '08030', '08035', '08033', '08045', '08049', '08109', '08059', '08107', '08110', '08078', '08081', '08083', '08084',
'08043', '08089', '08091', '08095', '08202', '08204', '08210', '08212', '08214', '08218', '08219', '08223', '08226', '08230',
'08242', '08243', '08245', '08246', '08247', '08248', '08250', '08251', '08252', '08260', '08270', '08302', '08311', '08313',
'08314', '08315', '08316', '08320', '08321', '08323', '08324', '08327', '08329', '08332', '08345', '08348', '08349', '08352',
'08353', '08360', '08361', '08362', '08014', '08020', '08312', '08025', '08322', '08027', '08028', '08032', '08039', '08328',
'08051', '08056', '08343', '08061', '08062', '08063', '08344', '08066', '08071', '08074', '08080', '08085', '08086', '08090',
'08093', '08094', '08096', '08097', '08520', '08525', '08534', '08540', '08541', '08542', '08543', '08544', '08550', '08560',
'08601', '08602', '08603', '08604', '08605', '08606', '08607', '08608', '08609', '08610', '08611', '08618', '08619', '08620',
'08625', '08628', '08629', '08638', '08645', '08646', '08647', '08648', '08650', '08666', '08677', '08690', '08691', '08695',
'08561', '07001', '07008', '07067', '08512', '08570', '08810', '08816', '08817', '08818', '08820', '08837', '08899', '08863',
'08828', '08904', '08830', '08832', '08824', '08840', '08846', '08850', '08852', '08831', '08901', '08903', '08905', '08906',
'08922', '08933', '08988', '08989', '08902', '08857', '08859', '08861', '08862', '08854', '08855', '08536', '07064', '08871',
'08872', '07077', '08879', '07080', '08877', '08882', '08884', '07095', '07710', '07709', '07711', '08501', '08720', '07712',
'07716', '07717', '07718', '07715', '07719', '07720', '08730', '08510', '07721', '07722', '08514', '07723', '07724', '07799',
'07726', '07704', '07727', '07703', '07728', '07730', '07732', '07731', '08526', '07734', '07735', '07737', '07738', '07739',
'07740', '08736', '07746', '07747', '07750', '07751', '07752', '07753', '07754', '07755', '07756', '07757', '08535', '07758',
'08555', '07760', '08750', '07702', '07762', '07763', '07764', '07765', '08005', '08006', '08721', '08008', '08722', '08723',
'08724', '08731', '08732', '08527', '08733', '08701', '08734', '08735', '08050', '08759', '08738', '08533', '08739', '08740',
'08741', '08742', '08751', '08752', '08753', '08754', '08755', '08756', '08757', '08087', '08758', '08092', '08001', '08023',
'08318', '08038', '08347', '08067', '08069', '08070', '08072', '08079', '08098');
$NJKevin = array(
'08037', '07401', '07620', '07621', '07603', '07072', '07010', '07624', '07626', '07627', '07628', '07073', '07020', '07407',
'07630', '07631', '07632', '07410', '07022', '07024', '07417', '07026', '07452', '07601', '07602', '07640', '07604', '07641',
'07642', '07423', '07605', '07643', '07644', '07071', '07430', '07495', '07498', '07607', '07432', '07645', '07074', '07646',
'07031', '07647', '07648', '07436', '07649', '07650', '07652', '07653', '07656', '07446', '07657', '07660', '07450', '07451',
'07661', '07662', '07070', '07663', '07458', '07606', '07666', '07670', '07608', '07699', '07676', '07463', '07057', '07675',
'07075', '07677', '07481', '07109', '07003', '07006', '07007', '07009', '07017', '07018', '07019', '07021', '07004', '07028',
'07111', '07039', '07040', '07041', '07042', '07043', '07101', '07102', '07103', '07104', '07105', '07106', '07107', '07108',
'07112', '07114', '07175', '07182', '07184', '07188', '07189', '07191', '07192', '07193', '07194', '07195', '07197', '07198',
'07199', '07110', '07050', '07051', '07068', '07078', '07079', '07044', '07052', '07002', '07029', '07030', '07097', '07302',
'07303', '07304', '07305', '07306', '07307', '07308', '07309', '07310', '07311', '07390', '07395', '07399', '07032', '07099',
'07047', '07094', '07096', '07087', '07086', '07093', '08801', '08802', '08803', '08804', '07830', '08809', '08822', '08825',
'08826', '08827', '08829', '08530', '08833', '08834', '08848', '08858', '08867', '07979', '08868', '08870', '08551', '08556',
'08557', '08885', '08559', '08887', '08888', '08889', '07733', '07777', '07748', '07701', '07005', '07926', '07828', '07405',
'07927', '07928', '07930', '07834', '07801', '07802', '07936', '07836', '07932', '07933', '07935', '07842', '07845', '07847',
'07034', '07849', '07850', '07852', '07035', '07853', '07940', '07945', '07946', '07803', '07045', '07950', '07960', '07961',
'07963', '07962', '07856', '07970', '07878', '07046', '07857', '07976', '07054', '07440', '07806', '07058', '07444', '07869',
'07457', '07866', '07870', '07980', '07876', '07082', '07885', '07981', '07983', '07999', '07403', '07011', '07012', '07013',
'07014', '07015', '07508', '07538', '07420', '07506', '07507', '07421', '07424', '07435', '07438', '07055', '07501', '07502',
'07503', '07504', '07505', '07509', '07510', '07513', '07514', '07522', '07524', '07533', '07543', '07544', '07442', '07456',
'07511', '07512', '07465', '07470', '07474', '07477', '07480', '07920', '07921', '08502', '07924', '08504', '08805', '08807',
'08812', '07931', '08821', '08823', '07934', '08844', '08528', '07938', '07939', '08835', '08836', '08853', '07977', '07978',
'08869', '08896', '08553', '08558', '08873', '08875', '08876', '08880', '07059', '07069', '08890', '07821', '07822', '07826',
'07890', '07416', '07837', '07418', '07839', '07419', '07422', '07843', '07848', '07851', '07428', '07855', '07827', '07860',
'07439', '07871', '07874', '07875', '07460', '07461', '07877', '07879', '07462', '07881', '07922', '07066', '07016', '07201',
'07202', '07206', '07207', '07208', '07023', '07027', '07205', '07033', '07036', '07092', '07974', '07060', '07061', '07062',
'07063', '07065', '07203', '07204', '07076', '07081', '07901', '07902', '07083', '07088', '07090', '07091', '07820', '07823',
'07825', '08808', '07829', '07831', '07832', '07833', '07838', '07840', '07844', '07846', '07863', '08865', '07865', '08886',
'07880', '07882');
//if ($zip2 == "08")
// {
// $Phorm_mailTo = "1name@email.com";
// } else
if (($zip2 >= "73") && ($zip2 <= "79"))
{
$Phorm_mailTo = "2name@email.com";
} else
if (($zip2 >= "30") && ($zip2 <= "31"))
{
$Phorm_mailTo = "3name@email.com";
} else
if (($zip2 >= "27") && ($zip2 <= "28"))
{
$Phorm_mailTo = "4name@email.com";
} else
if (($zip2 >= "80") && ($zip2 <= "81"))
{
$Phorm_mailTo = "5name@email.com";
} else
if (($zip2 >= "48") && ($zip2 <= "49"))
{
$Phorm_mailTo = "6name@email.com";
} else
if ($zip3 == "342")
{
$Phorm_mailTo = "7name@email.com";
} else
if (($zip3 >= "336") && ($zip3 <= "337"))
{
$Phorm_mailTo = "8name@email.com";
} else
if (($zip3 >= "332") && ($zip3 <= "334"))
{
$Phorm_mailTo = "9name@email.com";
} else
if (in_array($zip, $NJJim)) {
$Phorm_mailTo = "jsname@email.com";
} else
if (in_array($zip, $NJKevin)) {
$Phorm_mailTo = "kmname@email.com";
} else
{
$Phorm_mailTo = "jjname@email.com";
}
if (!$_POST['contact'][0]) { $error = $error."Please enter a First Name.
"; }
if (!$_POST['contact'][1]) { $error = $error."Please enter a Last Name.
"; }
if (!$_POST['contact'][6]) { $error = $error."Please enter a Telephone Number.
"; }
if (!$_POST['contact'][8]) { $error = $error."Please enter an Email Address.
"; }
if (!$_POST[contact][0] || !$_POST[contact][1] || !$_POST[contact][6] || !$_POST[contact][8]) {
//header("Location: $Phorm_err");
include("services_error.php");
exit;
} else {
if (ereg("^([0-9,a-z,A-Z]+)([.,_,-]([0-9,a-z,A-Z,]+))*([_,-])?[@]([0-9,a-z,A-Z]{3,})([_\,-]([0-9,a-z,A-Z]+))*[.]([0-9,a-z,A-Z]){2,3}([.]([0-9,a-z,A-Z]){2,3})?$", $_POST[contact][8])){
mail($Phorm_mailTo, $Phorm_subj, $Phorm_msg, $Phorm_headSend);
header("Location: $Phorm_ok");
} else {
//header("Location: $Phorm_err");
$error = $error."Please enter a valid Email Address.
";
include("services_error.php");
exit;
}
}
?>
Source: http://www.livejournal.com/community/php/373194.html