Home > PHP > PHP Code > How to send external html content mail using php?

How to send external html content mail using php?

Hi, The following code will work, this functionality is use the external html content as email body. And send mails with neatly formatted html content using simple php mailer class.

PHP Code

$mail = new PHPMailer();
$mail->IsMail();
$mail->Timeout  = 360;
$mail->From = "";
$mail->FromName = "";
$mail->AddReplyTo(“”);
$mail->AddAddress($Email);
$mail->IsHTML(true);
$mail->Subject = "Html as email";
$file = fopen("email.html","r");
$str=fread($file,filesize("email.html"));
$str = trim($str);
fclose($file);
$mail->Body    = $str;
$mail->Send();

Then it will send the external html file as email body.

But be sure that in the html file all images should be full path. like:

http://www.domain.com/images/[image name]

It will be helpful.

Thank you,

You may also like
Website uptime monitoring using PHP script
Understanding the basic need of MVC architecture
How to convert feeds to html using javascript and php
Multi-language support for web application with MySql and PHP

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.