我正在使用PHPmailer发送电子邮件.
我还使用了HTML = True内容类型
$mail = new PHPMailer();
$mail->IsSMTP(); // send via SMTP
$mail->Host = $Host;
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = $Username;
$mail->Password = $Password;
$mail->From = $From;
$mail->FromName = $FromName;
$mail->AddAddress($To , $ToName);
$mail->WordWrap = 50; // set word wrap
$mail->Priority = 1;
$mail->IsHTML(true);
$mail->Subject = $Subject;
$mail->Body = $Body;
Run Code Online (Sandbox Code Playgroud)
发送电子邮件后,我会看到实际的HTML代码而不是内容,请查看下面的内容
**不确定是什么问题**
Nab*_*imi 64
isHTML()
在设置实例Body
属性(我的意思$mail->Body
)之后调用方法解决了我的问题:
$mail->Subject = $Subject;
$mail->Body = $Body;
$mail->IsHTML(true); // <=== call IsHTML() after $mail->Body has been set.
Run Code Online (Sandbox Code Playgroud)
//原谅我的初学者的英语
有msgHTML()方法,它也调用IsHTML().
嗯...名字IsHTML
令人困惑......
/**
* Create a message from an HTML string.
* Automatically makes modifications for inline images and backgrounds
* and creates a plain-text version by converting the HTML.
* Overwrites any existing values in $this->Body and $this->AltBody
* @access public
* @param string $message HTML message string
* @param string $basedir baseline directory for path
* @param bool $advanced Whether to use the advanced HTML to text converter
* @return string $message
*/
public function msgHTML($message, $basedir = '', $advanced = false)
Run Code Online (Sandbox Code Playgroud)