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->Timeout  = 360;
$mail->From = "";
$mail->FromName = "";
$mail->Subject = "Html as email";
$file = fopen("email.html","r");
$str = trim($str);
$mail->Body    = $str;

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:[image name]

It will be helpful.

Thank you,

Anil Kumar Panigrahi

With more than 10 years experience in PHP and Founder of Anil Labs, a blog for PHP and related posts. contributed posts regarding CodeIgniter, CakePHP and Learn PHP online ... Contact : [email protected]

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

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