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

$mail = new phpmailer();

$mail->From       = "home@kidspages.org";
$mail->AddReplyTo = "home@kidspages.org";
$mail->FromName   = "Kids' Pages";
$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 Hunk-Ta-Bunk-Ta&reg; Music</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 Day Features<br />
        Hunk-Ta-Bunk-Ta<sup>&reg;</sup> Music<br />
        Thursday, January 4<br />
      </div>

      <div>
        <br />
        Join award-winning songwriter and recording artist Katherine Dines for Hunk-Ta-Bunk-Ta<sup>&reg;</sup> Music on Thursday, January&nbsp;4 at 11am at FlatIron Crossing for Family Fun Days. Kids can sing, jump, clap, and laugh along in this fun-filled, action-packed musical show! Participants can expect lots of interaction, movement, and some fun surprises that will entertain both kids and parents. Children will also have a chance to win many great prizes!<br />
        <br />
        Katherine Dines is a Grammy-nominated songwriter, a recording and teaching artist, and the creator of the award-winning Hunk-Ta-Bunk-Ta<sup>&reg;</sup> Music series.<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 Thursday, February&nbsp;1.<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 Day Features
Hunk-Ta-Bunk-TaŽ Music
Thursday, January 4

Join award-winning songwriter and recording artist Katherine Dines for Hunk-Ta-Bunk-TaŽ Music on Thursday, January 4 at 11am at FlatIron Crossing for Family Fun Days. Kids can sing, jump, clap, and laugh along in this fun-filled, action-packed musical show! Participants can expect lots of interaction, movement, and some fun surprises that will entertain both kids and parents. Children will also have a chance to win many great prizes!

Katherine Dines is a Grammy-nominated songwriter, a recording and teaching artist, and the creator of the award-winning Hunk-Ta-Bunk-TaŽ Music series.

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 Thursday, February 1.

EOT
;

  $mail->From     = "home@kidspages.org";
  $mail->FromName = "Kids' Pages";
  $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();
}
?>
