<?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 distinct 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>Kids' Pages Reader Appreciation Day at SixFlags!</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; }
  </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>

        Join Mr. Shine for a Free,<br />Fun-Filled Morning!<br />
        Thursday, November 2<br />at 11am!<br />
      </div>

      <div>
        <br />
        Bring the kids to FlatIron Crossing Thursday, November&nbsp;2 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 />
        And mark your calendars for Thursday, December&nbsp;7 for an extra special Family Fun Day! Kids can meet a star from Disney on Ice Disneyland Adventure, enter to win tickets to the show, and more!<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 />
        Call 303-277-0053 or 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, November 2
at 11am!

Bring the kids to FlatIron Crossing Thursday, November 2 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!

And mark your calendars for Thursday, December 7 for an extra special Family Fun Day! Kids can meet a star from Disney on Ice Disneyland Adventure, enter to win tickets to the show, and more!

Flatiron Crossing is located in Broomfield at US36 at the Flatiron Crossing Circle Exit.

Call 303-277-0053 or visit KidsPages.org for more information.

EOT
;

  $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();
}
?>
