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

$mail = new phpmailer();

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

@MYSQL_CONNECT( "localhost", "kp_pnmonkey", "buster" );
@mysql_select_db( "kp_phoenix" );


// $query  = "SELECT distinct email_address FROM kp_emails";
$query  = "select distinct email_address from kp_emails where email_address not in (select email_address from kp_emails_block)";

$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>Family Fun Day Features Music & Movement Show</title>
  <style>
    a         { color:#d06f1a }
    a:link    { font-weight: bold; text-decoration: none; }
    a:hover   { font-weight: bold; text-decoration: underline; }
    a:active  { font-weight: bold; text-decoration: none; }
    sup {
    font-size: smaller;
    vertical-align: baseline;
    position: relative;
    bottom: 0.33em;
    }
  </style>
</head>

<body bgcolor="#b7d98c" text="#4b3905" 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" style="font-size:20px;font-weight:bold;color:#d06f1a;">
        <div style="float:left;padding-right:10px;padding-top:10px;padding-bottom:10px;">
          <img src="http://kidspages.org/newsletter/images/2006-09-li-dino.gif" width="300" height="334" border="0">
        </div>
        Family Fun Days Features<br />
        Animal Expeditions with<br />
        the Denver Zoo<br />
        Thursday, March 1<br />
        at FlatIron Crossing!
      </div>

      <div>
        <br />
        Join us On Thursday, March 1 at 11am! The Denver Zoo will present "Animal Expeditions," where families can meet live animals with amazing adaptations from different habitats all around the world at FlatIron Crossing for Family Fun Days. Children will also have a chance to win many great prizes!<br />
        <br />
        Flatiron Crossing is located in Broomfield at US36 at the Flatiron Crossing Circle Exit. (<a href="http://maps.google.com/maps?f=q&hl=en&q=1+W+Flatiron+Cir,+Broomfield,+CO&ie=UTF8&z=15&om=1" target="_blank">See map</a>)<br />
        <br />
        Brought to you by Kids' Pages Family Magazine, the resource for metro area families! Visit <a href="http://kidspages.org/modules.php?op=modload&name=Sections&file=index&req=viewarticle&artid=5015" target="_blank">KidsPages.org</a> for more information!<br />
        <br />
        Join Kids' Pages Family Magazine at FlatIron Crossing in Broomfield the first Thursday of every month for a free fun-filled morning! Family Fun Days at FlatIron feature a variety of educational and entertaining activities for young children. Enjoy prizes, great entertainment, giveaways, and much more. Watch your email for information about the next Family Fun Day on March &nbsp;1 with the Denver Zoo.<br />
        <br />
      </div>

      <div align="center"><a href="http://kidspages.org" target="_blank"><img src="http://kidspages.org/newsletter/images/2006-09-li-kplogo.gif" width="552" height="102" border="0"></a></div>
    </div>
  </div>
</body>
</html>

EOT
;

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

Family Fun Days Features
Animal Expeditions with
the Denver Zoo
Thursday, March 1
at FlatIron Crossing!

Join us On Thursday, March 1 at 11am! The Denver Zoo will present "Animal Expeditions," where families can meet live animals with amazing adaptations from different habitats all around the world at FlatIron Crossing for Family Fun Days. Children will also have a chance to win many great prizes!

With facilities in Ft. Collins and Louisville, Mountain Center offers a variety of movement and learning opportunities for children, teens, and adults including gymnastics, dance, preschool, swimming, and summer camp.

Flatiron Crossing is located in Broomfield at US36 at the Flatiron Crossing Circle Exit. (See map)

Brought to you by Kids' Pages Family Magazine, the resource for metro area families! Visit KidsPages.org for more information!

Join Kids' Pages Family Magazine at FlatIron Crossing in Broomfield the first Thursday of every month for a free fun-filled morning! Family Fun Days at FlatIron feature a variety of educational and entertaining activities for young children. Enjoy prizes, great entertainment, giveaways, and much more. Watch your email for information about the next Family Fun Day on March  1 with the Denver Zoo.

EOT
;

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

  $mail->Body    = $body;
  $mail->AltBody = $text_body;
  $mail->Subject = "Join Kids' Pages Family Magazine at FlatIron Crossing!";
  $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();
}

  echo "<br />";
  echo "### COMPLETE ###<br />";
?>
