December 6th, 2012, 07:55 AM
Email Form sending the emailer a copy
I have managed to get so far with my email form and it send to both the admin and also the email address entered for the sender.
But, the admin email is received in HTML and looks fine but when the sender receives the email its all HTML code and is unreadable.
Can someone please help me as i don't understand why this is happening.
Thanks in advance
$senderName = $_POST['userName'];
$senderEmail = $_POST['userEmail'];
$senderSubject = $_POST['userSubject'];
$senderMessage = $_POST['userMsg'];
$senderName = stripslashes($senderName);
$senderEmail = stripslashes($senderEmail);
$senderMessage = stripslashes($senderMessage);
$to = 'email address goes here' . ', ';
$to .= $senderEmail;
$from = "$senderEmail ";
$subject = "$senderSubject";
$message = <<<EOF
<b>Name</b> : $senderName<br /><br />
<b>Email</b> : <a href="mailto:$senderEmail">$senderEmail</a><br /><br />
<b>Subject</b> : $senderSubject<br /><br />
<b>Message</b> : $senderMessage<br />
$headers = "From: $from\r\n";
$headers .= "Content-type: text/html\r\n";
$to = "$to";
mail($to, $subject, $message, $headers, $senderEmail);
December 6th, 2012, 08:10 AM
Please use [ PHP ] tags rather than [ CODE ] tags for your PHP. See the sticky at the top of this forum.
The reason has nothing to do with your PHP per se. The reader being used either is not capable of rendering HTML or has HTML turned off. This is a real world situation thus it requires you to modify your email to accommodate it.
You need to generate a multi-part email that can be rendered either with an HTML capable reader or a plain text reader. This should help.
There are 10 kinds of people in the world. Those that understand binary and those that don't.
December 6th, 2012, 08:34 AM
Thank you for getting back to me, i'll check out the link.
Originally Posted by gw1500se