I have a script that I am using to process form data and send a custom email based on the variables sent by the form. I've spent a couple days trying to get this to work with no luck. This is my first post ever to a PHP forum, and I'm anxious to see if someone will be able to help me out with this issue. Here is the code I am using now, but the php script within the email does not seem to work (One other note I'd like to mention is that the Blind Carbon Copy BCC email does not get mailed for some reason if I leave the Carbon Copy CC empty, so feel free to help with that also. THANKS!):
Here's My Bad Code:
<?php
foreach ($_POST as $key => $value){
$emailtext .= $key . " = " .$value ."\n\n";
$EmailHeaders = "From:
test@test.com" . "\r\n" . "CC:" . "\r\n" . "BCC:";
}
mail("
test@test.com", $_POST[TestNumber], $emailtext . "\n\n" . $req, $EmailHeaders);
//Sends Email To Customer
if ( $_POST[Variable1] == "sendEmail" OR $_POST[Variable2] == "sendEmail" OR $_POST[Variable3] == "sendEmail")
{
$CustTO = "$_POST[customer_name] <$_POST[customer_email]>" ;
$CustCC = "";
$CustCC = "
MyEmail@MyDomain.com";
$CustSubject = "Here is Your Email!";
$CustBody = "
<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.0 Transitional//EN'>
<HTML>
<HEAD>
<META content='text/html; charset=iso-8859-1' http-equiv=Content-Type>
</HEAD>
<BODY>
<DIV><IMG style='WIDTH: 750px; HEIGHT: 90px' border=0 hspace=0 alt='My Logo' align=textTop src='
http://MyDomain.com/folder/banner.jpg'></DIV><BR>
<DIV><FONT size=2 face=Helvetica, Arial>$_POST[first_name],</FONT></DIV><BR>
<DIV><FONT size=2 face=Helvetica, Arial><STRONG>Thank you for your visit!</STRONG></FONT></DIV><BR>
<DIV><FONT size=2 face=Helvetica, Arial>You can instantly view your link(s) below:</FONT></DIV><BR>
//Here is the part that does not work like I'd expect it to:
<?php
if ( $_POST[Variable1] == 'SendEmail')
echo {<DIV><FONT size=2 face=Helvetica, Arial><STRONG>$_POST[LinkName]:</STRONG></FONT><BR>
<FONT size=2 face=Helvetica, Arial><A href=http://www.MyDomain.com/links/$_POST[linknumber1].pdf>
http://www.MyDomain.com/links/$_POST[linknumber1].php[/url]</FONT></DIV><BR>;}
?>
//I think everything else is fine from here down:
<DIV><FONT size=2 face=Helvetica, Arial><STRONG>$_POST[LastLink]:</STRONG></FONT><BR>
<FONT size=2 face=Helvetica, Arial><A href=http://www.MyDomain.com/downloads/$_POST[lastlink].pdf>
http://www.MyDomain.com/links/$_POST[lastLink].php[/url]</FONT></DIV><BR>
<DIV><FONT size=2 face=Helvetica, Arial><STRONG>Note: </STRONG>You will need Adobe Acrobat Reader to view/print instant download products. If you don't already have this program, you can install a free copy here:</FONT><BR>
<FONT size=2 face=Helvetica, Arial><A href='
http://get.adobe.com/reader/'>http://get.adobe.com/reader/[/url]</FONT></DIV><BR>
<DIV><FONT size=2 face=Helvetica, Arial><STRONG>Thanks again for visiting our site!</STRONG></FONT></DIV><BR>
<DIV><IMG border=0 hspace=0 alt='My Logo' align=baseline src='
http://MyDomain.com/logo.jpg'></DIV>
</BODY>
</HTML>
";
$CustFrom = "My Name <
MyEmail@MyDomain.com>";
$CustHeaders = "From:$CustFrom" . "\r\n" . "BCC:MyEmail@MyDomain.com";
$CustHeaders .= "MIME-Version: 1.0" . "\r\n";
$CustHeaders .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
mail($CustTO,$CustSubject,$CustBody,$CustHeaders);
}
else
{
}
?>