<?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 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 Mr. Shine</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:700;">
      <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>
        Join Mr. Shine for a Free,<br />Fun-Filled Morning!<br />
        <br />
        Thursday, September 6<br />
        11am at FlatIron Crossing!<br />
        <br />
        First Show of the Season!<br />
      </div>
      <br />

      <div>
        Bring the kids to FlatIron Crossing Thursday, September&nbsp;6 at 11am for Kids' Pages Family Fun Day!<br />
        <br />
        Join Mr. Shine, children's songwriter and performer, and get ready to sing, jump, clap and laugh at this fun-filled, action-packed musical show for preschoolers!<br />
        <br />
        Children will sing songs about dinosaurs, lions, and some popular nursery rhymes, too. Get ready for plenty of interaction, movement and some fun surprises that will entertain both kids and parents.<br />
        <br />
        This activity is free of charge and open to kids of all ages. Located in Dillard's Court at FlatIron Crossing in Broomfield. Family Fun Days are ideal activities for playgroups!<br />
        <br />
        FlatIron Crossing is located at US36 at the East & West FlatIron Crossing Drive Exits.<br />
        (<a href="http://maps.google.com/maps?q=1+W+Flatiron+Cir,+Broomfield,+CO+(FlatIron+Crossing)" 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 />
      </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

Join Mr. Shine for a Free,
Fun-Filled Morning!

Thursday, September 6
11am at FlatIron Crossing!

First Show of the Season!

Bring the kids to FlatIron Crossing Thursday, September 6 at 11am for Kids' Pages Family Fun Day!

Join Mr. Shine, children's songwriter and performer, and get ready to sing, jump, clap and laugh at this fun-filled, action-packed musical show for preschoolers!

Children will sing songs about dinosaurs, lions, and some popular nursery rhymes, too. Get ready for plenty of interaction, movement and some fun surprises that will entertain both kids and parents.

This activity is free of charge and open to kids of all ages. Located in Dillard's Court at FlatIron Crossing in Broomfield. Family Fun Days are ideal activities for playgroups!

FlatIron Crossing is located at US36 at the East & West FlatIron Crossing Drive Exits.

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

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 />";
?>
