Click here to Skip to main content
13,260,330 members (42,920 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Hi i am using php mailer to sending mails.But i need to send the HTML content in php mail i refer lot of site all are says IsHTML(true) function is used to send HTML content in php mail.But its not working for me.

This is my coding.
function smtpmailer($to, $to_cc, $to_bcc, $from, $from_name, $subject, $body) {
global $error;
$mail = new PHPMailer();
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host  = "";
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "ssl"; // sets the prefix to the servier
$mail->Host = ""; // sets GMAIL as the SMTP server
$mail->Port = 465; // set the SMTP port for the GMAIL server
$mail->Username = "************"; // GMAIL username
$mail->Password = "********"; // GMAIL password
$mail->SetFrom($from, $from_name);
$mail->Subject = $subject;
$mail->Body = $body;
if(!$mail->Send()) {
$error = 'Mail error: '.$mail->ErrorInfo;
print $error;
return false;
} else {
$error = 'Message sent!';
print $error;
return true;

Please help me to solve this.
Posted 8-Feb-13 18:35pm
Sandeep Mewara 9-Feb-13 14:44pm
elaborate 'not working' a little - you see raw html? escaped data? what exactly?

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

For HTML mails, consider adding plain text version, i.e.

$textBody = 'My text-only body....';

most likely it will solve your issue, as content/type will become multipart/alternative, and you will target wider amount of browsers.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.171114.1 | Last Updated 9 Feb 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100