Scott
Scott

Reputation: 11

HTML showing as plain text body in PHPMailer

I feel embarassed to ask this because I have seen this question asked several times. However none of the solutions seem to be working for me. My HTML is output as plain text in the body of e-mail sent through PHPMailer

I have read the PHPMailer documentation on Github and found answers like this PHPmailer sending HTML CODE and this Add HTML formatting in phpmailer on stackoverflow.

    //Create a new PHPMailer instance
    $mail = new PHPMailer(true);
    // Set PHPMailer to use the sendmail transport
    $mail->isSendmail();
    //Set who the message is to be sent from
    $mail->setFrom('[email protected]');
    //Set an alternative reply-to address
    //    $mail->addReplyTo('[email protected]', 'First Last');
    //Set who the message is to be sent to
    $mail->addAddress('[email protected]');
    //Set the subject line
    $mail->Subject = 'Rework Report';

    $body = file_get_contents('current/rework.txt');
    $mail->Body= $body;
    $mail->IsHTML = (true);

   //Attach a file
   //$mail->addAttachment('current/rework.txt');
   //send the message, check for errors
   if (!$mail->send()) {
        echo "Mailer Error: " . $mail->ErrorInfo;
    } else {
        echo "Message sent!";
    }

The output should be HTML in the body of the e-mail.

Upvotes: 0

Views: 832

Answers (1)

seantunwin
seantunwin

Reputation: 1768

As per the PHPmailer sending HTML CODE link in your question, you likely need to change:

// From
$mail->IsHTML = (true);
// To -- i.e. remove the equals sign (=)
$mail->IsHTML(true);

As it appears to be a function as opposed to a variable.

Upvotes: 1

Related Questions