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.

 

Link to comment
Share on other sites

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     = "youremail@address.com";
  $mail->FromName = "Your email name";
  $mail->AddAddress($emailaddress,$name);
  $mail->AddReplyTo("youremail@address.com","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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.