简体   繁体   English

使用 phpmailer 通过 email 发送 html 页面

[英]Send html page by email with phpmailer

I'm trying to send this html page via email.我正在尝试通过 email 发送此 html 页面。 It's done by unlayer.com.它由 unlayer.com 完成。 I've tested with $mail->isHtml(true), ... msgHtml... But in email client always see the code or part of the code instead of the html page.... Do you have any idea?我已经用 $mail->isHtml(true), ... msgHtml... 进行了测试,但是在 email 客户端总是看到代码或代码的一部分,而不是 html 页面......你有什么想法吗? Thanks !!!谢谢 !!!

This is my code:这是我的代码:

 $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();

and the code I need to send is in this link: (I cannot copy paste in this input so it was weir)我需要发送的代码在这个链接中:(我不能在这个输入中复制粘贴,所以很奇怪)

https://app.guvavet.com/testenviaremail.php https://app.guvavet.com/testenviaremail.php

Many thanks for all your help.非常感谢您的帮助。

$mail->msgHTML(file_get_contents('yourHtml.html'), __DIR__); //Read an HTML message body from an external file, convert referenced images to embedded,
$mail->AltBody = 'HTML messaging not supported'; // If html emails is not supported by the receiver, show this body

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

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