【发布时间】:2021-04-07 12:05:50
【问题描述】:
我正在尝试通过电子邮件发送此 html 页面。这是由 unlayer.com 完成的。我已经用 $mail->isHtml(true), ... msgHtml 进行了测试... 但在电子邮件客户端中,总是看到代码或部分代码,而不是 html 页面...... 你有什么主意吗? 谢谢!!!
这是我的代码:
$sql = "SELECT * FROM Idiomes_Lin WHERE Id = 992";
$stmt = $con->prepare($sql);
$stmt->execute();
$row = $stmt->fetch();
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
//Enviar Email
require 'PHPMailer-master/src/Exception.php';
require 'PHPMailer-master/src/PHPMailer.php';
require 'PHPMailer-master/src/SMTP.php';
include ("emaildata.php");
$mail = new PHPMailer(true);
$mail->CharSet = "UTF-8";
$mail->SMTPDebug = 4;
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = SMTP_HOST; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = SMTP_UNAME; // SMTP username
$mail->Password = SMTP_PWORD; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->AuthType = 'tls';
$mail->Port = SMTP_PORT;
$mail->SMTPOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);// TCP port to connect to
$mail->From = 'it@ipe-innovaciones.com';
$mail->FromName = 'IT';
// Mail del sol·licitant
$mail->addAddress('it@ipe-innovaciones.com'); // Add a recipient
$mail->Subject = 'Test email';
$Missatge = $row['Nom1'];
$mail->Body = html_entity_decode($Missatge);
$mail->isHTML(true);
$mail->send();
我需要发送的代码在这个链接中:(我不能在这个输入中复制粘贴,所以很奇怪)
https://app.guvavet.com/testenviaremail.php
非常感谢您的帮助。
【问题讨论】:
-
为什么您的实体要以编码开头?您可以毫无问题地将原始 HTML 存储在数据库中。没有像
tls这样的AuthType;您可能根本不需要设置它。如果您无法准确解释禁用 TLS 验证的原因,您可能不应该这样做。