Jump to content

PHP mail function doesn't send html mail


Recommended Posts



I'm following w3schools' PHP tutorial and i'm trying to send an html mail:


But the HTML part of the mail doesn't work, i get my mail with all the html tags written literally, like this:


Is something missing?


This is my code:

$msg = "<html>
<title>HTML email</title>
<p>This email contains HTML Tags!</p>
// More headers
$headers .= 'From: <webmaster@example.com>' . "\r\n";
$headers .= 'Cc: myboss@example.com' . "\r\n";
// use wordwrap() if lines are longer than 70 characters
$msg = wordwrap($msg,70);
// send email
mail("felipepinoredes@gmail.com","Formulario Idea",$msg);
Edited by harry_ord
Link to comment
Share on other sites

You have to add a Content-Type header to the e-mail.

$headers .= 'Content-Type: text/html' . "\r\n";

Then add the headers when sending the e-mail:

mail("felipepinoredes@gmail.com","Formulario Idea",$msg, $headers);
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...