I want to send an Newsletter with PHPMAiler. The newsletter does work, but I'm wondering if there is a better option to do this.
What I have is.
- HTML Page
- Images
Now my code looks as follows
$mail = new PHPMailer();
//Adding the body
$body = file_get_contents('template/index.htm');
$mail->Subject = "PHPMailer Test Subject via mail(), basic";
$mail->AltBody = "To view this message, please use an HTML compatible email viewer!";
$mail->SetFrom('xxxxxxx', 'xxxxxxxxxx');
$address = "[email protected]";
$mail->AddAddress($address, "xxxxxxx");
$mail->AddEmbeddedImage("template/images/bullet_point.gif","1");
$mail->AddEmbeddedImage("template/images/template_1_01.gif","2");
$mail->AddEmbeddedImage("template/images/template_1_03.gif","3");
$mail->MsgHTML($body);
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
I use file_get_contents to get the html page, and AddEmbeddedImage to embed images, now is there a way to pass only the HTML page to PHPMailer and that PHP Mailer will embed these images automatically?