I am sending several emails through phpmailer, however in some emails it does not finish showing the images, for example in gmail or yahoo.
I am doing it this way:
/*=============================================
VERIFICACIÓN DE CORREO ELECTRÓNICO PHPMAILER
=============================================*/
//$url = "https://www.url.com/";
date_default_timezone_set("Europe/Madrid");
$url = Ruta::ctrRuta();
//echo "Por ahora la url es: ".$url;
$mail = new PHPMailer;
$mail->CharSet = 'UTF-8';
$mail->isMail();
$mail->setFrom('[email protected]', 'título');
$mail->addReplyTo('[email protected]', 'Ttítulo');
$mail->Subject = "¡Confirma tu direccion de email!";
$mail->addAddress($_POST["emailNewsletter"]);
//Prueba con ruta entera de la imagen.
$imagen1 = '<img src="https://www.url.com/views/images/imagen.jpg" alt="Ttitulo" class="img-newsletter">';
$mail->msgHTML('
<img src="'.$url.'views/images/imagen.jpg" alt="Titulo" class="img-newsletter">
<p>Otra prueba de imagen con la ruta entera directa</p>
'.$imagen1.'
');
//Prueba de imagen adjunta.
$mail->AddAttachment("https://www.url.com/views/images/imagen.jpg");
$envio = $mail->Send();
//Si no se envía phpmailer
if(!$envio){
//Error en la verificación
echo '<p class="alerta-confirmacion">!Error al verificar newsletter a tu dirección de correo electrónico!</p>';
echo $_POST["regEmail"].$mail->ErrorInfo.'!';
}
//Confirmación de correo enviado al usuario
else{
//Si se envía phpmailer y va todo bien
echo '<p class="alerta-confirmacion">!No olvides verificar tu dirección de correo electrónico para confirmar tu registro!</p>';
}
Here I have only put the part of the code that affects that area as an example, where I have tried with the variable $url
that is equal to the entire path of the server, also with $imagen1
where I put the entire path of img including the entire path of the image and even with a test image attached and none of the three works.
What am I doing wrong?
Well, the truth is that I am responding to this topic again since I thought it was going to be a "Hotlink Protection" topic and yet at the last minute trying this option without putting https and putting the normal image path it seems to work correctly in both cases .
I don't know if you still have that problem with https because of that error you mention about avoiding direct links to other pages, so I'll have to check that part again and check it on the server. But as I indicate in the example, it already works correctly.
Greetings.