Jump to content

Emailing an html file within the body of the email


vozzek

Recommended Posts

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.

 

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.