vozzek Posted March 5, 2008 Share Posted March 5, 2008 Hi all, My website is going to be sending our customers a monthly newsletter to give them advanced notice of upcoming sales. I constructed the newsletter itself as a simple newsletter.html file, consisting of a few hyperlinks and photos. This file will be changed monthly. Now I'm writing a mail script to send the newsletter, but I don't want to send it as an attachment. What I'd like is all of the code within the newsletter.html file to show up in the body of the email. I was going to use 'include' to do this, but so far the body of my emails are coming up empty. I think I'm way off. Can someone recommend the best way to do this? Thanks in advance. Link to comment https://forums.phpfreaks.com/topic/94513-emailing-an-html-file-within-the-body-of-the-email/ Share on other sites More sharing options...
shocker-z Posted March 5, 2008 Share Posted March 5, 2008 I use a mailer class called php mailer http://phpmailer.codeworxtech.com/ Then using this code <?php $mail = new PHPMailer(); $mail->IsSMTP(); $mail->Host = "127.0.0.1"; $mail->From = "[email protected]"; $mail->FromName = "Your email name"; $mail->AddAddress($emailaddress,$name); $mail->AddReplyTo("[email protected]","Your email name"); // $mail->AddEmbeddedImage('E:/liam/logo/logo.gif','logo','logo.gif'); $mail->WordWrap = 50; $mail->IsHTML(true); $mail->Subject = "BKSB website results"; $body=file_get_contents('C:/php/includes/email.html'); $mail->Body = $body; if(!$mail->Send()) { echo "Message was not sent <p>"; echo "Mailer Error: " . $mail->ErrorInfo; exit; } ?> That will do the trick i've commented out the bit where i attach my logo as not sure if you want this, however if you do then to insert the image attached called logo use this in your html file. <IMG SRC="cid:bksblogo"> Regards Liam Link to comment https://forums.phpfreaks.com/topic/94513-emailing-an-html-file-within-the-body-of-the-email/#findComment-483974 Share on other sites More sharing options...
vozzek Posted March 5, 2008 Author Share Posted March 5, 2008 Thanks much, Liam! The 'file_get_contents' command worked like a charm. Perfect! Link to comment https://forums.phpfreaks.com/topic/94513-emailing-an-html-file-within-the-body-of-the-email/#findComment-484218 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.