skip to Main Content

We’ve recently upgraded to a Plesk Parallel Linux Server and it appears as if the PHP settings are ignoring headers! The emails are receiving fine, but display the HTML tags.

The phpInfo() file can be viewed here: https://www.pressgofer.com/phpInfo.php

The PHP itself should be okay, but have included it here anyway.

PHP Mail Code

$email = "[email protected]";
$message = "<h1 style='font-family:Helvetica,Arial;font-size:17px'>Your account has a password reset request</h1>";

$headers = "From: [email protected] rn";
$headers .= "Reply-To:  [email protected] rn";
$headers .= "MIME-Version: 1.0rn";
$headers .= "Content-Type: text/html; charset=ISO-8859-1rn";

mail($email, "Reset password notification", $message, $headers);

Many thanks,
Nick

2

Answers


  1. Chosen as BEST ANSWER

    sending mail from php: headers are interpreted as body?

    Issue was associated with MIME type and server interpretation- no r needed.


  2. your phpinfo shows that mail.add_x_header is OFF. you need to turn it on

    To enable the X-Mail header, set mail.add_x_header to 1 in your php.ini

    <?php
    $to = "[email protected]";
    $subject = "My HTML email test.";
    $headers = "From: [email protected]";
    $headers .= "Reply-To: [email protected]";
    $headers .= "Return-Path: [email protected]";
    $headers .= "MIME-Version: 1.0rn";
    $headers .= "Content-Type: text/html; charset=ISO-8859-1rn";
    
    $message = "<html><body>";
    $message .= "<h1> This is a test </h1>";
    $message .= "</body></html>";
    
    if ( mail($to,$subject,$message,$headers) ) {
       echo "The email has been sent!";
       } else {
       echo "The email has failed!";
       }
    ?> 
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search