PHP email shows html source code in Apple Mail

541 Views Asked by At

I am sending an html email and the email shows perfectly fine everywhere except it shows the source code instead of the content in Apple mail.

Here is what I've done:

$to = "";
$subject = "";
$message = '
<html>
<head>
<title>New Inquiry From Quick Contact Form</title>
</head>
<body>
<table border="0" width="100%" cellspacing="0" cellpadding="0" bgcolor="#F4F3F4">
<tbody>
<tr>
<td style="padding: 15px;">Name:</td>
</tr>
<tr>
<td style="padding: 15px;">Last Name:</td>
</tr>
</tbody>
</table>
</body>
</html>
';

$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$headers .= 'From: "<support@mydomain>"' . "\r\n";
mail($to,$subject,$message,$headers);

Note: The HTML in my "message" variable above is just sample. I have a valid HTML in my actual development. I think I am doing something wrong with my headers.

Any help is highly appreciated!

Thanks,

1

There are 1 best solutions below

0
On

Not sure, it it will help, but I would try to use phpmailer class, as it makes headers more accurate (google for download phpmailer class). Also you can send e-mails using g-mail smtp server (google for php send email through gmail).