Jump to content

mail() HTML email not working


teebo

Recommended Posts

Hi,

 

I have just signed up to a Virtual Server and I'm having issues with sending email via mail() in HTML format.  I have a simple script to test the server and it's not working correctly.  The receiving server does not understand it's an HTML email.  On another server, this script works perfectly:

 

$to = "[email protected]";
$subject = "HTML email";

$message = "
<html>
<head>
<title>HTML email</title>
</head>
<body>
<p>This email contains HTML Tags!</p>
<table>
<tr>
<th>Firstname</th>
<th>Lastname</th>
</tr>
<tr>
<td>John</td>
<td>Doe</td>
</tr>
</table>
</body>
</html>
";

// Always set content-type when sending HTML email
$headers = 'From: <[email protected]>' . "\r\n";
$headers .= "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=utf-8" . "\r\n";

// More headers


mail($to,$subject,$message,$headers);

Link to comment
https://forums.phpfreaks.com/topic/46650-mail-html-email-not-working/
Share on other sites

Whats the actuall issue? Does the server not send the email?  Or do you mean when someone reads it, it doesnt treat it as html?  if its the latter, i take it the recipient has a html enabled email browser? Sometimes hotmail etc doesnt allow html in emails so therefore will display as a standard text mail.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.