Reputation: 11
I'm trying to send this html page via email. It's done by 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? 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 = '[email protected]';
$mail->FromName = 'IT';
// Mail del sol·licitant
$mail->addAddress('[email protected]'); // 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
Many thanks for all your help.
Upvotes: 0
Views: 220
Reputation: 1735
$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
Upvotes: 1