PHP 科杜姆
例如,我将 HTML 代码视为纯文本
<blockquote> <p><strong>hello</strong></p>
//Server settings
$mail->isSMTP(); //Send using SMTP
$mail->Host = settings('smtpHost'); //Set the SMTP server to send through
$mail->SMTPAuth = true; //Enable SMTP authentication
$mail->Username = settings('smtpUsername'); //SMTP username
$mail->Password = settings('smtpPassword'); //SMTP password
$mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; //Enable implicit TLS encryption
$mail->Port = settings('smtpPort'); //TCP port to connect to; use 587 if you have set `SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS`
//Recipients
$mail->setFrom(settings('smtpSendMail'), settings('smtpName'));
//Content
$mail->isHTML(true);
$mail->CharSet = 'utf-8';
//Set email format to HTML
$mail->Subject = $subjectMail;
$mail->Body = $bodyMail;
邮件中显示Html代码
我在 Youtube 上观看了视频并查看了有关堆栈溢出的旧线程,但我无法解决问题。
我在 PHPMailer 中遇到了同样的问题,我发现以下解决方案适用于我的代码。
$mail->Body = nl2br($html);