简体   繁体   English

PhpMailer 发送 email 内容仅显示纯文本,不包含 HTML styles

[英]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.. 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 ,我不知道为什么会这样。。

Here i attach PhpMailer function,这里我附上 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,下面我附上summernote视图代码,

<!--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?任何人都可以找到解决此问题的方法吗?

You are removing all your HTML tags with the strip_tags function.您将使用strip_tags function 删除所有 HTML 标签。

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

Just pass $content without the strip_tags function.只需传递$content而不使用strip_tags function。

If you are using PHPMailer then you may use如果您使用的是 PHPMailer,那么您可以使用

$mail->isHTML(true);

That will work for html format.这适用于 html 格式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM