9951 explained code solutions for 126 technologies


phpmailerHow do I set the content-type to text/html in PHPMailer?


In order to set the content-type to text/html in PHPMailer, you need to use the isHTML() method. This method takes a boolean value as a parameter, where true indicates that the content is HTML, and false indicates that the content is plain text. For example:

$mail->isHTML(true);

The output of this code is nothing, since it is a method that sets a flag.

Code explanation

  • $mail - An instance of PHPMailer
  • isHTML() - Method of PHPMailer that sets the content-type
  • true - Parameter passed to isHTML() to indicate that the content is HTML

Helpful links

Edit this code on GitHub