I'm using the following code to send an HTML email with an attachment (zip) and if it works.
What I want is to make changes for:
1. Send an HTML template already pre-made containing CSS (it's in an external file).
2. Embed (not attach) any image in the message.
3. Send to several recipients at the same time.
<?php
date_default_timezone_set('Etc/UTC');
require 'PHPMailer/PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->isSMTP();
$mail->CharSet = 'UTF-8';
$mail->SMTPDebug = 0;
$mail->Debugoutput = 'html';
$mail->Host = 'smtp.gmail.com';
$mail->Port = 587;
$mail->SMTPSecure = 'tls';
$mail->SMTPAuth = true;
$mail->SMTPOptions = array(
'ssl' => array('verify_peer' => false,'verify_peer_name' => false,'allow_self_signed' => true)
);
$mail->Username = "[email protected]";
$mail->Password = "mipassword";
$mail->setFrom('[email protected]', 'No responder');
$mail->Subject = 'Probando mensaje';
$mail->Body = "<h1>Mensaje HTML</h1><br><br>desde PHPMailer<br>";
$mail->AltBody = 'No se para que sirve';
$mail->addAttachment('adjuntar/paquete.zip');
$mail->addAddress('[email protected]', 'Nombre Destinatario');
if (!$mail->send()) {
echo "Error al enviar: " . $mail->ErrorInfo;
} else {
echo "¡Mensaje enviado!";
}
?>