HTML not formatting in mail function

I am using the following code:

$message = "Hi ".$user.
  ",\r\rThe following names are on the guestlist for <b>".$night.
  "</b> on ".$date2.":\r\r". $user ."<br>". implode(", ", $names).
  "\r\rThank you for using Guestvibe.";

mail($email, "Your Guestvibe list", $message);

The carriage returns in PHP are working fine, but neither the <b> or <br> tags are coming out. Is it just my mail client (Apple Mail) playing up, or is there a fix for this?


You are sending the e-mail as text only not HTML, I believe you need to set these headers:

$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";

as in example #4 of the docs.

PHP's mail function sends plaintext mail by default.

See the nr.4 example at mail's manual page for the correct way to send HTML mail.

You need to add your headers:

$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

mail($email, "Your Guestvibe list", $message, $headers);

You should firstly wrap the whole message into:

<html><head></head><body> msg </body></html>

Plus headers from m.edmondson post.

Need Your Help

Oracle SQL Retrieve Data From End of Month - 16th And 15th - 1st

sql oracle system-databases

Alright so I am trying to retrieve data a field we will call DATE_OF_ENTRY and the field is like this.

Intent Service getting killed after sometime

android android-service android-sensors intentservice

I have implemented an intent service in my application, the purpose of which is to monitor the device's shake on a continuous basis.According to the requirement,whenever a shake is detected ,this i...