harry_ord Posted October 9, 2016 Share Posted October 9, 2016 (edited) Hello I'm following w3schools' PHP tutorial and i'm trying to send an html mail:http://www.w3schools.com/php/func_mail_mail.asp 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:<?php $msg = "<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> "; // 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); if ($_SERVER["REQUEST_METHOD"] == "POST") { // send email mail("felipepinoredes@gmail.com","Formulario Idea",$msg); } ?> Edited October 9, 2016 by harry_ord Link to comment Share on other sites More sharing options...
dsonesuk Posted October 9, 2016 Share Posted October 9, 2016 You need at least a 'from' header in $headers variable. Link to comment Share on other sites More sharing options...
Ingolme Posted October 10, 2016 Share Posted October 10, 2016 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 More sharing options...
harry_ord Posted October 10, 2016 Author Share Posted October 10, 2016 Thanks, Tails!I didn't know about the header stuff, now is working and i can send more presentable messages. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now