Click here to Skip to main content
11,709,537 members (52,179 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: PHP
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 17:35pm
Sandeep Mewara at 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
0 Sergey Alexandrovich Kryukov 590
1 OriginalGriff 250
2 Maciej Los 225
3 Peter Leow 219
4 Mika Wendelius 160
0 OriginalGriff 9,428
1 Sergey Alexandrovich Kryukov 9,027
2 CPallini 5,189
3 Maciej Los 4,991
4 Mika Wendelius 3,856

Advertise | Privacy | Mobile
Web02 | 2.8.150819.1 | Last Updated 9 Feb 2013
Copyright © CodeProject, 1999-2015
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