[Solved] Email not displaying HTML [closed]


This as per your original post https://stackoverflow.com/revisions/36426850/1

Here’s the deal. Your code has a missing > for <h1HELLO WORLD!</h1> so that’ll need to be changed to <h1>HELLO WORLD!</h1>.

Edit: Ah, now you edited that in now https://stackoverflow.com/revisions/36426850/2, yet the following still applies.

Then the “chain link” broke in $headers = "MIME-Version: 1.0" . "\r\n"; where there’s a missing dot/concatenate.

$headers .= "MIME-Version: 1.0" . "\r\n";

Then you’re using 5 parameters in the headers which won’t work. There is a 5th for mail() but that’s for something entirely different.

Read the manual on it:

You also on top of that, don’t have anything assigned to $message1 yet that would be useless to use anyway.


Add error reporting to the top of your file(s) which will help find errors.

<?php 
error_reporting(E_ALL);
ini_set('display_errors', 1);

// Then the rest of your code

Sidenote: Displaying errors should only be done in staging, and never production.


Edit:

Another thing is that you need to create new headers to get the other mail sent as HTML, and that is most likely why you said it wasn’t sending as HTML.

Only the first mail sent will be HTML and not the second one. Consult one of my answers on Stack to do this https://stackoverflow.com/a/18382062/ and add new HTML headers for each of them, using different variables for each header just as you did for $headers2 and apply that to your code using the same way you used the HTML for $headers.

5

solved Email not displaying HTML [closed]