PHPMailer IsHTML(true)不工作 [英] PHPMailer IsHTML(true) not working

查看:441
本文介绍了PHPMailer IsHTML(true)不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从PHPMailer发送电子邮件。一切正常,但问题是即使在写入 $ mail-> IsHTML(true); 之后,也会发送电子邮件与HTML标签。以下是我发送电子邮件的代码。

I am trying to send emails from PHPMailer. Everything is working but the problem is it is sending emails along with HTML tags even after writing $mail->IsHTML(true); . Below is my code for sending emails.

    $mail = new PHPMailer(); 
    $mail->IsSMTP();
    $mail->SMTPDebug = 1;
    $mail->SMTPAuth = true; 
    $mail->SMTPSecure = EMAIL_COMPOSE_SECURE; 
    $mail->Host = EMAIL_COMPOSE_SMTP_HOST;  
    $mail->Port = EMAIL_COMPOSE_PORT;
    $mail->Username = EMAIL_COMPOSE_OUTGOING_USERNAME;
    $mail->Password = EMAIL_COMPOSE_OUTGOING_PASSWORD;
    $mail->SetFrom(EMAIL_COMPOSE_INCOMING_USERNAME);
    $mail->Subject =$subject;

    $mail->Body = $message;
    $mail->IsHTML(true);
    $mail->AddAddress($email_to);
    if(!$mail->Send()){
        echo "Mailer Error: " . $mail->ErrorInfo;
    }
    else{
      echo "Message has been sent";
    }

还有一件事我会提到,在我的应用程序文本编辑器中编写电子邮件是ckeditor。会造成任何问题吗?请帮助。

And one more thing I will mention, in my application text editor for writing the emails is ckeditor. Will that cause any problem? Please help.

推荐答案

为什么如果您调用 IsHTML(真)?这就是你告诉PHPMailer将您的邮件正文视为HTML!如果您不希望HTML作为内容类型,请调用 IsHTML(false),或者只是不要调用它,因为纯文本是默认的。

Why would you not expect it to use HTML if you call IsHTML(true)? That's how you tell PHPMailer to treat your message body as HTML! If you don't want HTML as the content type, call IsHTML(false), or just don't call it at all since plain text is the default.

如果你想要HTML和纯文本,请调用 msgHTML($ html),它也将处理HTML->

If you want both HTML and plain text, call msgHTML($html) instead and it will also handle the HTML->text conversion for you.

正如Chris所说,在设置之前调用 IsHTML 正文

As Chris said, call IsHTML before setting Body.

正如Dagon所说,如果把HTML放在$ code $ message ,它将发送HTML ...

And as Dagon said, if you put HTML in $message, it will send HTML...

这篇关于PHPMailer IsHTML(true)不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆