Search code examples
phphtmlcodeigniterphpmailersummernote

PhpMailer Sent email content is show only plain text not contain with HTML styles


I use PhpMailer library in codeigniter for send an email, email sending process are working fine, i use summernote for write my email content, summernote generate HTML format what i edit in summernote, but while i send an email, recieved mail have just plain text, i don't know why it's happen..

Here i attach PhpMailer function,

function send_email_common_method($email_id,$password,$to,$subject,$content,$attach_file,$ccmailarray,$bccmailarray,$email_id_name) {
  include_once(APPPATH."third_party/PHPMailer/PHPMailerAutoload.php");
  $mail = new PHPMailer;
  $mail->IsHTML(true);
  $mail->isSMTP();
  $mail->Host = 'smtp.gmail.com';
  $mail->Port = 465;//587
  $mail->SMTPSecure = 'ssl';
  $mail->SMTPAuth = true;
  $mail->Username = $email_id;
  $mail->Password = $password;
  $mail->setFrom($email_id, $email_id_name);
  $mail->addAddress($to);
  $mail->Subject = $subject;
  $mail->msgHTML(strip_tags($content));
  $mail->addAttachment($attach_file);
  foreach($ccmailarray as $ccarray)
  {
    $mail->AddCC($ccarray);
  }
  foreach($bccmailarray as $bccarray)
  {
    $mail->AddBCC($bccarray);
  }
  //print_r($mail);exit;
  if (!$mail->send()) {
    $error = "Mailer Error: " . $mail->ErrorInfo;
    return 0;
  //echo '<p id="para">'.$error.'</p>';exit;
  }
  else {
    return 1;
  }

}

And below i attach summernote view code,

<!--Wysiwyg editor : Summernote placeholder-->
<textarea name="reply_content_email" class="reply_content_email" id
   ="reply-mailbox-mail-compose"></textarea>
<p class="text-danger" id="reply_content_email_err"></p>
<!-- <div ></div> -->
<div class="pad-ver">
   <!--Send button-->
   <button id="mail-send-btn" type="submit" name="btn_submit"  class="btn btn-primary">
   <i class="mailbox-psi-mail-send icon-lg icon-fw"></i> Reply Mail
   </button>
</div>

Any one can find a solution for this issue?


Solution

  • You are removing all your HTML tags with the strip_tags function.

    $mail->msgHTML(strip_tags($content));
    

    Just pass $content without the strip_tags function.