I’m having trouble with my email confirmation. They inconsistently not being sent to the people who submitted the form. I’m not sure whether I have my PHP code set-up correctly. The following is my PHP Code for my email confirmation:
<?php
$to="";
$subject="";
$message="";
$headers="";
/*Payment Email Method*/
if ($paymentMethod == "Paypal") {
$emailPayment = "Credit Card/Paypal";
} else {
$emailPayment = "Check<br/>
<br/>
Payment Instructions here.
<br/>";
}
$to = $email;
$subject = "Registration Confirmation";
$message = '<html>
<body>
Content introduction here. <br/><br/>
Registrant Information<br/>
----------------------------------------------------------<br/>
Name: '.$name.'<br/>
Title: '.$title.'<br/>
Address: '.$address1.'<br/>
Address 2: '.$address2.'<br/>
'.$city.', '.$state.' '.$zip.'<br/>
Home Phone: '.$phone.'<br/>
Office Phone: '.$office.'<br/>
Fax: '.$fax.'<br/>
Email: '.$email.'<br/>
<br/>
<br/>
Method of Payment<br/>
----------------------------------------------------------<br/>
'.$emailPayment.'<br/>
<br/>
Registration Type<br/>
----------------------------------------------------------<br/>
'.$emailReg.'<br/>
<br/>
Credits<br/>
----------------------------------------------------------<br/>
'.$emailCredit.'<br/>
<br/>
Cost<br/>
----------------------------------------------------------<br/>
Initial Conference Fee: $'.$emailCost1.'<br/>
CE Credit Option Fee: $'.$emailCost2.'<br/>
-----<br/>
Grand Total: $'.$totalCost.'<br/>
</body>
</html>';
$headers = "MIME-Version: 1.0\\r\
";
$headers .= "Content-type: text/html; charset=iso-8859-1\\r\
";
$headers .= "From: My Website <website@mywebsite.com>\\r\
";
$headers .= "CC: me@mywebsite.com\\r\
";
if (mail($to, $subject, $message, $headers)) {
echo(" ");
} else {
echo("<p>Message delivery failed.</p>");
}
?>
Is the if and else function for mail set-up correctly? Or should I just remove the else function because it’s not needed to echo whether a person’s message failed?
Please let me know. Any help is appreciated. Thanks!