<?php
require("class.phpmailer.php");

$mail = new phpmailer();

$mail->From     = "home@kidspages.org";
$mail->FromName = "Kids' Pages";
$mail->Mailer   = "mail";

@MYSQL_CONNECT( "localhost", "kp_pnmonkey", "buster" );
@mysql_select_db( "kp_phoenix" );
$query  = "SELECT email_address FROM kp_emails";
$result = @MYSQL_QUERY($query);

while ( $row = mysql_fetch_array ( $result ) )
{
  // HTML body
$body =
<<<EOT
<html>
<head>
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  <title>Chedd's Coupon</title>
  <style>
    a         { color:#ffff00 }
    a:link    { font-weight: bold; text-decoration: none; }
    a:hover   { font-weight: bold; text-decoration: underline; }
    a:active  { font-weight: bold; text-decoration: none; }
  </style>
</head>

<body bgcolor="#e96615" text="#000000" link="#0000ff" vlink="#0000ff" alink="#0000ff">
  <div align="center">
    <div align="left" style="font-family:verdana,geneva,serif; font-size:14px; font-weight:bold; padding:10px; width:80%;">
      <div align="center"><a href="http://www.chedds.com" target="_blank"><img src="http://kidspages.org/newsletter/images/cheddslogo.gif" width="281" height="68" border="0"></a></div>
      <br />
      <div align="center" style="font-size:20px;font-weight:bold;color:#ffff00;">Chedd's Gourmet Grilled Cheese<br />The Best Grilled Cheese in Town!</div>

      <p>Chedd's Gourmet Grilled Cheese &mdash; Yummy! &mdash; During the months of March and April, when you bring in your Kid's Pages coupon for a Free Kid's meal with an adult purchase, you will also receive a $2.00 off coupon for your next visit! This is in addition to the free drink and side already included with the Kids Meal (we call them Lil-Skeeters). Just bring in this e-mail to redeem (limit one coupon per order).</p>

      <p>Chedd's Gourmet Grilled Cheese has been recognized as the Best Grilled Cheese Sandwich in Denver in The Best of Westword, Top of the Rocky of the Denver Post, Readers choice in 5280 Magazine, and Best of CitySearch among others over the last 2 years! Check us out at <a href="http://www.chedds.com" target="_blank">www.chedds.com</a></p>

      <p>We even have Free Wisconsin Dairy Farm Coloring Books for your kids to take home!</p>

      <p>This offer is good at our Littleton location only. We are located at 8966 W. Bowles Ave., Unit O. We are across from the S.W. Plaza 1/4 mile west of Wadsworth. 303-948-2421.</p>
    </div>
  </div>
</body>
</html>
EOT
;

// Plain text body (for mail clients that cannot read HTML)
$text_body  =
<<<EOT

Chedd's Gourmet Grilled Cheese
The Best Grilled Cheese in Town!

Chedd's Gourmet Grilled Cheese -- Yummy! -- During the months of March and April, when you bring in your Kid's Pages coupon for a Free Kid's meal with an adult purchase, you will also receive a $2.00 off coupon for your next visit! This is in addition to the free drink and side already included with the Kids Meal (we call them Lil-Skeeters). Just bring in this email to redeem (limit one coupon per order).

Chedd's Gourmet Grilled Cheese has been recognized as the Best Grilled Cheese Sandwich in Denver in The Best of Westword, Top of the Rocky of the Denver Post, Readers choice in 5280 Magazine, and Best of CitySearch among others over the last 2 years! Check us out at www.chedds.com

We even have Free Wisconsin Dairy Farm Coloring Books for your kids to take home!

This offer is good at our Littleton location only. We are located at 8966 W. Bowles Ave., Unit O. We are across from the S.W. Plaza 1/4 mile west of Wadsworth. 303-948-2421.

EOT
;

  $mail->Body    = $body;
  $mail->AltBody = $text_body;
  $mail->Subject = "Yummy!";
  $mail->AddAddress( $row["email_address"] );
//  $mail->AddAddress($row["email_address"], $row["full_name"]);
//  $mail->AddStringAttachment($row["photo"], "YourPhoto.jpg");

  if(!$mail->Send())
  {
    echo "There has been a mail error sending to " . $row["email_address"] . "<br>";
  }
  else
  {
    echo "Success sending to " . $row["email_address"] . "<br>";
  }

  // Clear all addresses and attachments for next loop
  $mail->ClearAddresses();
  $mail->ClearAttachments();
}
?>
