<?php
ini_set( "max_execution_time", 3600 );
require("class.phpmailer.php");

$mail = new phpmailer();

$mail->From       = "eBlast@kidspages.org";
$mail->AddReplyTo = "eBlast@kidspages.org";
$mail->FromName   = "Kids' Pages Family";
$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) ) and ( email_address not in (select email from kp_ebook_unsubscribe) ) and ( email_address not in (select email from kp_ebook_sent ) )";

// $query = "select distinct email_address from kp_emails where email_address not in (select email_address from kp_emails_block)";
// $query = "select distinct email_address from kp_emails where ( email_address not in (select email_address from kp_emails_block) ) and ( email_address not in (select email from kp_ebook_unsubscribe) )"

echo '### Start: ' . date('l jS \of F Y h:i:s A') . "<br />";

$result = @MYSQL_QUERY($query);

$numrows = mysql_num_rows( $result );
echo "$numrows addresses to process... <br />";
$count = 0;

while ( $row = mysql_fetch_array ( $result ) )
{
  $email_address = $row["email_address"];
  $count++;

// HTML body
$body =
<<<EOT


<html>
<head>
<title>KidsPages.org - FREE Family Fun!</title>
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="center" bgcolor="#FFFFFF">
<table border="0" cellpadding="0" cellspacing="0" width="575">
<tr>
<td align="left" bgcolor="#FFFFFF" height="50" valign="top"><a href="http://kidspages.org" target="_blank"><img alt="kidspages.org" src="http://kidspages.org/newsletter/images/2009-04-01/KidsPagesLogo-0904.gif" width="384" height="80" border="0" /></a></td>
<td align="right" bgcolor="#FFFFFF" height="50" style="line-height:0px; font-size:0px;" valign="top">&nbsp;</td>
</tr>
<tr>
<td colspan="2">
<hr color="#B7CD60" noshade="noshade" size="1px">
</td>
</tr>
<tr>
<td colspan="2">
<div style="font-family:Arial, Helvetica, sans-serif;font-size:25px;font-weight:bold;padding-bottom:6px;color:#594022;">
<div style="font-size:15px;color:black;line-height:150%;">
<p style="margin: 0 0 4px 0">FREE Family Fun Galore!</p>
<p style="margin: 0 0 4px 0"><a href="http://KidsPages.org" target="_blank">Click here</a> to visit your Complete Family Resource for<br />Festivities and Family Fun throughout the Front Range!</p>
</div>
</div>
</td>
</tr>
<tr>
<td height="100%" valign="top">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<!-- Sesame Street Live -->
<tr>
<td align="left" bgcolor="#FFFFFF" height="100%">
<table border="0" cellpadding="0" cellspacing="0" height="100%" width="381">
<tr>
<td colspan="2" height="12" rowspan="2" style="line-height:0px; font-size:0px;" width="12"><img height="12" src="http://kidspages.org/newsletter/images/2008-04-01/color001_ul_corner.jpg" width="12" alt="" /></td>
<td bgcolor="#9A9B96" height="1px" style="line-height:0px; font-size:0px;" width="357"></td>
<td colspan="2" height="12" rowspan="2" style="line-height:0px; font-size:0px;" width="12"><img height="12" src="http://kidspages.org/newsletter/images/2008-04-01/color001_ur_corner.jpg" width="12" alt="" /></td>
</tr>
<tr><td bgcolor="#E2E5D2" height="11" style="line-height:0px; font-size:0px;"></td></tr>
<tr>
<td bgcolor="#9A9B96" height="100%" style="line-height:0px; font-size:0px;" width="1"></td><td bgcolor="#E2E5D2" height="100%" style="line-height:0px; font-size:0px;" width="11"></td>
<td align="left" bgcolor="#E2E5D2" height="100%" style="font-size: 12px; color:#343436; line-height:16px;" valign="top">
<div style="font-family:Arial, Helvetica, sans-serif;font-size:25px;line-height:27px;font-weight:bold;padding-bottom:2px;color:#005bab;">
Help Elmo find a new home for Sunny in Sesame Street Live's "Elmo's Green Thumb"
</div>
<font style="font-family:Arial, Helvetica, sans-serif;font-size:14px;line-height:21px;">
<div style="float:right;padding: 5px 0px 5px 5px;"><a href="http://www.sesamestreetlive.com" target="_blank"><img src="http://kidspages.org/newsletter/images/2009-04-01/SesameStreetLive.gif" width="250" height="164" border="0" alt="" /></a></div>
<p>Sunny isn't just the weather forecast on Sesame Street -- it's also the name of Elmo's sunflower friend! Join all your favorite friends on an amazing adventure as they help Elmo find a new home for Sunny when Sesame Street Live "Elmo's Green Thumb" performs at Ritchie Center, Magness Arena on the University of Denver Campus from <b>Thursday, April 16 through Sunday, April 19.</b></p>
<strong>
To charge tickets by phone, call Ticketmaster at 800-745-3000. Tickets may also be purchased online at <a href="http://www.ticketmaster.com" target="_blank">www.ticketmaster.com</a>. For information online, please visit <a href="http://www.sesamestreetlive.com" target="_blank">www.sesamestreetlive.com</a>.
</strong>
</font>
</td>
<td bgcolor="#E2E5D2" height="100%" width="11"></td><td bgcolor="#9A9B96" height="100%" width="1"></td>
</tr>
<tr><td colspan="5" style="line-height:0px; font-size:0px;"><img height="12" src="http://kidspages.org/newsletter/images/2008-04-01/color001_bottom.jpg" width="381" alt="" /></td></tr>
<tr><td colspan="5" style="line-height:0px; font-size:0px;"><img height="14" src="http://kidspages.org/newsletter/images/2008-04-01/pix.gif" width="1" alt="" /></td></tr>
</table>
</td>
</tr>
<!-- /Sesame Street Live -->
<!-- Harkins -->
<tr>
<td align="left" bgcolor="#FFFFFF" height="100%">
<table border="0" cellpadding="0" cellspacing="0" height="100%" width="381">
<tr>
<td colspan="2" height="12" rowspan="2" style="line-height:0px; font-size:0px;" width="12"><img height="12" src="http://kidspages.org/newsletter/images/2008-04-01/color001_ul_corner.jpg" width="12" alt="" /></td>
<td bgcolor="#9A9B96" height="1px" style="line-height:0px; font-size:0px;" width="357"></td>
<td colspan="2" height="12" rowspan="2" style="line-height:0px; font-size:0px;" width="12"><img height="12" src="http://kidspages.org/newsletter/images/2008-04-01/color001_ur_corner.jpg" width="12" alt="" /></td>
</tr>
<tr><td bgcolor="#E2E5D2" height="11" style="line-height:0px; font-size:0px;"></td></tr>
<tr>
<td bgcolor="#9A9B96" height="100%" style="line-height:0px; font-size:0px;" width="1"></td><td bgcolor="#E2E5D2" height="100%" style="line-height:0px; font-size:0px;" width="11"></td>
<td align="left" bgcolor="#E2E5D2" height="100%" style="font-size: 12px; color:#343436; line-height:16px;" valign="top">
<div style="font-family:Arial, Helvetica, sans-serif;font-size:25px;line-height:27px;font-weight:bold;padding-bottom:2px;color:#005bab;">
Summer Movie Fun at<br />Harkins Theater
</div>
<font style="font-family:Arial, Helvetica, sans-serif;font-size:14px;line-height:21px;">
<div style="float:right;padding: 5px 0px 5px 5px;"><a href="http://www.harkinstheatres.com" target="_blank"><img src="http://kidspages.org/newsletter/images/2009-04-01/HarkinsLogo.gif" width="250" height="134" border="0" alt="" /></a></div>
<p>Season tickets for Harkins Theatres' popular 10 week Summer Movie Fun program will be on sale at <b>Harkins Northfield 18</b> on Friday, April 17 at 10am. Season tickets are $5 for all<br />10 movies -- prices even a recession can't argue with!</p>
<p><b>Summer movie fun begins Monday, May 25 through Friday, July 31.</b> Featuring a different family movie each week for 10 weeks for an unbeatable $5, Summer Movie Fun promises again to be the best value for children all summer.</p>
<p><b>Visit <a href="http://www.harkinstheatres.com" target="_blank">www.harkinstheatres.com</a><br />or call 1-800-601-4SMF.</b></p>
</font>
</td>
<td bgcolor="#E2E5D2" height="100%" width="11"></td><td bgcolor="#9A9B96" height="100%" width="1"></td>
</tr>
<tr><td colspan="5" style="line-height:0px; font-size:0px;"><img height="12" src="http://kidspages.org/newsletter/images/2008-04-01/color001_bottom.jpg" width="381" alt="" /></td></tr>
<tr><td colspan="5" style="line-height:0px; font-size:0px;"><img height="14" src="http://kidspages.org/newsletter/images/2008-04-01/pix.gif" width="1" alt="" /></td></tr>
</table>
</td>
</tr>
<!-- /Harkins -->
<!-- Avid -->
<tr>
<td align="left" bgcolor="#FFFFFF" height="100%">
<table border="0" cellpadding="0" cellspacing="0" height="100%" width="381">
<tr>
<td colspan="2" height="12" rowspan="2" style="line-height:0px; font-size:0px;" width="12"><img height="12" src="http://kidspages.org/newsletter/images/2008-04-01/color001_ul_corner.jpg" width="12" alt="" /></td>
<td bgcolor="#9A9B96" height="1px" style="line-height:0px; font-size:0px;" width="357"></td>
<td colspan="2" height="12" rowspan="2" style="line-height:0px; font-size:0px;" width="12"><img height="12" src="http://kidspages.org/newsletter/images/2008-04-01/color001_ur_corner.jpg" width="12" alt="" /></td>
</tr>
<tr><td bgcolor="#E2E5D2" height="11" style="line-height:0px; font-size:0px;"></td></tr>
<tr>
<td bgcolor="#9A9B96" height="100%" style="line-height:0px; font-size:0px;" width="1"></td><td bgcolor="#E2E5D2" height="100%" style="line-height:0px; font-size:0px;" width="11"></td>
<td align="left" bgcolor="#E2E5D2" height="100%" style="font-size: 12px; color:#343436; line-height:16px;" valign="top">
<div style="font-family:Arial, Helvetica, sans-serif;font-size:25px;line-height:27px;font-weight:bold;padding-bottom:2px;color:#005bab;">
Avid4 Adventure Day Camps
</div>
<font style="font-family:Arial, Helvetica, sans-serif;font-size:14px;line-height:21px;">
<div style="float:right;padding: 5px 0px 5px 5px;"><a href="http://www.Avid4.com" target="_blank"><img src="http://kidspages.org/newsletter/images/2009-04-01/avid4adventure.gif" width="234" height="242" border="0" alt="" /></a></div>
<p>Avid4 Adventure Day Camps offers fun, diverse, age-appropriate & safety-focused outdoor adventures for kids age 5-12. In each one-week session, kids Rock Climb, Mountain Bike, Hike, Kayak, & Canoe! They've served thousands of kids with their mobile school program and camps and are American Camp Association Accredited and Licensed by the State of Colorado. Day Camps are conveniently located in Denver, Highlands Ranch, Longmont, Boulder and Golden / Wheat Ridge.</p>
<div style="float:right;padding: 5px 0px 5px 5px;"><a href="http://www.Avid4.com" target="_blank"><img src="http://kidspages.org/newsletter/images/2009-04-01/avidkids.jpg" width="230" height="173" border="0" alt="" /></a></div>
<p><b>Are your kids ready for overnight camp?</b> Avid4 Adventure also has sleep-away and traveling camps for 8-15 year olds.</p>
<p><b>Check out <a href="http://www.Avid4.com" target="_blank">www.Avid4.com</a> for all the information.</b></p>
<p><b>SAVE $15: Register online by April 15 and use the coupon code "kidspages" to save $15 on each registration.</b></p>
</font>
</td>
<td bgcolor="#E2E5D2" height="100%" width="11"></td><td bgcolor="#9A9B96" height="100%" width="1"></td>
</tr>
<tr><td colspan="5" style="line-height:0px; font-size:0px;"><img height="12" src="http://kidspages.org/newsletter/images/2008-04-01/color001_bottom.jpg" width="381" alt="" /></td></tr>
<tr><td colspan="5" style="line-height:0px; font-size:0px;"><img height="14" src="http://kidspages.org/newsletter/images/2008-04-01/pix.gif" width="1" alt="" /></td></tr>
</table>
</td>
</tr>
<!-- /Avid -->
<!-- WOW Museum -->
<tr>
<td align="left" bgcolor="#FFFFFF" height="100%">
<table border="0" cellpadding="0" cellspacing="0" height="100%" width="381">
<tr>
<td colspan="2" height="12" rowspan="2" style="line-height:0px; font-size:0px;" width="12"><img height="12" src="http://kidspages.org/newsletter/images/2008-04-01/color001_ul_corner.jpg" width="12" alt="" /></td>
<td bgcolor="#9A9B96" height="1px" style="line-height:0px; font-size:0px;" width="357"></td>
<td colspan="2" height="12" rowspan="2" style="line-height:0px; font-size:0px;" width="12"><img height="12" src="http://kidspages.org/newsletter/images/2008-04-01/color001_ur_corner.jpg" width="12" alt="" /></td>
</tr>
<tr><td bgcolor="#E2E5D2" height="11" style="line-height:0px; font-size:0px;"></td></tr>
<tr>
<td bgcolor="#9A9B96" height="100%" style="line-height:0px; font-size:0px;" width="1"></td><td bgcolor="#E2E5D2" height="100%" style="line-height:0px; font-size:0px;" width="11"></td>
<td align="left" bgcolor="#E2E5D2" height="100%" style="font-size: 12px; color:#343436; line-height:16px;" valign="top">
<div style="font-family:Arial, Helvetica, sans-serif;font-size:25px;line-height:27px;font-weight:bold;padding-bottom:2px;color:#005bab;">
WOW! Children's Museum
</div>
<font style="font-family:Arial, Helvetica, sans-serif;font-size:14px;line-height:21px;">
<div style="float:right;padding: 5px 0px 5px 5px;"><a href="http://www.recreation.du.edu/passcamp" target="_blank"><img src="http://kidspages.org/newsletter/images/2009-04-01/WOWMuseum.gif" width="220" height="226" border="0" alt="" /></a></div>
<p>Howdy Partners! Dust off your cowboy boots and your ten gallon hat and join WOW! Children's Museum on <b>Saturday, May 2, 2009</b> at the Colorado National Golf Club in Erie for <b>Wild Ol' West, WOW!'s 4th Annual Auction & Casino Night Fundraiser!</b> Come enjoy cocktails, buffet dinner, live and silent auctions, casino gaming tables and much more! Proceeds benefit the 2009 WOW! Scholarship Fund and 2009 Education Exhibits and Programs!</p>
<p><b>Purchase tickets early and get a discount! Early Bird Tickets: $70 per person. All tickets can be purchased online at: <a href="http://www.wowmuseum.com" target="_blank">www.wowmuseum.com</a> or by calling the Museum at: 303-604-2424. Remember this event is for adults so please leave your little buckaroos at home!</b></p>
</font>
</td>
<td bgcolor="#E2E5D2" height="100%" width="11"></td><td bgcolor="#9A9B96" height="100%" width="1"></td>
</tr>
<tr><td colspan="5" style="line-height:0px; font-size:0px;"><img height="12" src="http://kidspages.org/newsletter/images/2008-04-01/color001_bottom.jpg" width="381" alt="" /></td></tr>
<tr><td colspan="5" style="line-height:0px; font-size:0px;"><img height="14" src="http://kidspages.org/newsletter/images/2008-04-01/pix.gif" width="1" alt="" /></td></tr>
</table>
</td>
</tr>
<!-- /WOW Museum -->
<!-- The Arvada Center Children's Theater -->
<tr>
<td align="left" bgcolor="#FFFFFF" height="100%">
<table border="0" cellpadding="0" cellspacing="0" height="100%" width="381">
<tr>
<td colspan="2" height="12" rowspan="2" style="line-height:0px; font-size:0px;" width="12"><img height="12" src="http://kidspages.org/newsletter/images/2008-04-01/color001_ul_corner.jpg" width="12" alt="" /></td>
<td bgcolor="#9A9B96" height="1px" style="line-height:0px; font-size:0px;" width="357"></td>
<td colspan="2" height="12" rowspan="2" style="line-height:0px; font-size:0px;" width="12"><img height="12" src="http://kidspages.org/newsletter/images/2008-04-01/color001_ur_corner.jpg" width="12" alt="" /></td>
</tr>
<tr><td bgcolor="#E2E5D2" height="11" style="line-height:0px; font-size:0px;"></td></tr>
<tr>
<td bgcolor="#9A9B96" height="100%" style="line-height:0px; font-size:0px;" width="1"></td><td bgcolor="#E2E5D2" height="100%" style="line-height:0px; font-size:0px;" width="11"></td>
<td align="left" bgcolor="#E2E5D2" height="100%" style="font-size: 12px; color:#343436; line-height:16px;" valign="top">
<div style="font-family:Arial, Helvetica, sans-serif;font-size:25px;line-height:27px;font-weight:bold;padding-bottom:2px;color:#005bab;">
The Arvada Center Children's Theater presents <strong><em>Just So</em></strong>
</div>
<font style="font-family:Arial, Helvetica, sans-serif;font-size:14px;line-height:21px;">
<div style="float:right;padding: 5px 0px 5px 5px;"><a href="http://arvadacenter.org/on-stage/just-so" target="_blank"><img src="http://kidspages.org/newsletter/images/2009-01-01/ArvadaCenter-JustSo.gif" width="210" height="209" border="0" alt="" /></a></div>
<p>This enchanting musical, with wild and zany characters, reveals the mysteries about some strange jungle animals. Based on Rudyard Kiplings' <em>Just So Stories</em>, this tale of courage, individuality and friendship will delight the young and young at heart.</p>
<strong>
Now to May 9<br />
Weekday general admission tickets: $8<br />
Weekend reserved tickets: $10<br />
<p>For more information and to purchase tickets, please visit <a href="http://arvadacenter.org/on-stage/just-so" target="_blank">arvadacenter.org/on-stage/just-so</a> or call 720-898-7200.</p>
</strong>
<div style="float:left;padding: 5px 5px 0px 0px;">
<a href="http://arvadacenter.org/on-stage/just-so" target="_blank"><img src="http://kidspages.org/newsletter/images/2009-04-01/ArvadaCenter-logo.gif" width="270" height="97" border="0" alt="" /></a>
</div>
</font>
</td>
<td bgcolor="#E2E5D2" height="100%" width="11"></td><td bgcolor="#9A9B96" height="100%" width="1"></td>
</tr>
<tr><td colspan="5" style="line-height:0px; font-size:0px;"><img height="12" src="http://kidspages.org/newsletter/images/2008-04-01/color001_bottom.jpg" width="381" alt="" /></td></tr>
<tr><td colspan="5" style="line-height:0px; font-size:0px;"><img height="14" src="http://kidspages.org/newsletter/images/2008-04-01/pix.gif" width="1" alt="" /></td></tr>
</table>
</td>
</tr>
<!-- /The Arvada Center Children's Theater -->
</table>
</td>
<td align="right" height="100%" valign="top">
<table border="0" cellpadding="0" cellspacing="0" width="177">
<tr>
<td colspan="5" style="line-height:0px; font-size:0px;"><img alt="Kids' Pages eBlast" src="http://kidspages.org/newsletter/images/2009-04-01/kphead.gif" width="177" height="59"></td>
</tr>
<tr>
<td bgcolor="#999999" height="100%" width="1"></td>
<td bgcolor="#E3EDB9" height="100%" width="11"></td>
<td align="center" bgcolor="#E3EDB9" height="100%" style="font-family:Arial, Helvetica, sans-serif;font-size:12px; color:#343436;padding-bottom:3px; line-height:16px;" valign="top" width="153">
<br />
<!-- Sidebar: Camp Guide -->
<div align="center" style="font-size:17px; line-height: 19px; font-weight:bold; color:#4e5670;">
The Family Guides You've Been Waiting For!
</div>
<br />
<!-- /Sidebar: Camp Guide -->
<!-- Sidebar: Party Time! -->
<div style="padding-right:0px;padding-top:0px;padding-bottom:10px;">
<a href="http://kidspages.org/2009/04/monthly-feature/2009-birthday-party-guide" target="_blank"><img src="http://kidspages.org/newsletter/images/2009-04-01/birthdayguide.jpg" width="150" height="225" border="0" alt="" /></a>
</div>
<div align="center" style="font-size:17px; line-height: 19px; font-weight:bold; color:#4e5670;">
Party Time!
</div>
<div style="text-align:center;line-height:150%;">
<p style="margin-top:5px;">You don't have to be a millionaire or a party planner to throw a memorable birthday bash for your child, all you need is Kids' Pages Birthday Party Guide! Packed with information and resources on quality birthday party entertainers, rentals, venues and so much more! <a href="http://kidspages.org/2009/04/monthly-feature/2009-birthday-party-guide" target="_blank">Click here</a> and let's get your party started!</p>
<p style="margin-top:0px;"><a href="http://kidspages.org/2009/04/monthly-feature/2009-birthday-party-guide" target="_blank">Read it now.</a></p>
</div>
<br />
<!-- /Sidebar: Party Time! -->
<!-- Sidebar: Camp Guide -->
<div style="padding-right:0px;padding-top:0px;padding-bottom:10px;">
<a href="http://kidspages.org/2009/03/monthly-feature/2009-summer-camps-guide" target="_blank"><img src="http://kidspages.org/newsletter/images/2009-04-01/campkids.gif" width="150" height="170" border="0" alt="" /></a>
</div>
<div align="center" style="font-size:17px; line-height: 19px; font-weight:bold; color:#4e5670;">
Time for Camp!
</div>
<div style="text-align:center;line-height:150%;">
<p style="margin-top:5px;">
Summer is almost here! Time to keep the kids entertained, engaged and educated without breaking the family budget. Whether it's drama camp, art camp or good-ole day camp, there are so many quality camps to choose from in Kids' Pages Summer Camp Guide! <a href="http://kidspages.org/2009/03/monthly-feature/2009-summer-camps-guide" target="_blank">Click here</a> to start your quest.
</p>
<p style="margin-top:0px;"><a href="http://kidspages.org/2009/03/monthly-feature/2009-summer-camps-guide" target="_blank">Read it now.</a></p>
</div>
<br />
<!-- /Sidebar: Camp Guide -->
</td>
<td bgcolor="#E3EDB9" height="100%" style="line-height:0px; font-size:0px;" width="11"></td>
<td bgcolor="#999999" height="100%" style="line-height:0px; font-size:0px;" width="1"></td>
</tr>
<tr>
<td colspan="5" style="padding: 0 0 14px 0; line-height:0px; font-size:0px;"><img border="0" height="12" src="http://kidspages.org/newsletter/images/2008-04-01/kpbook_bottom.jpg" width="177" alt="" /></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
<table align="center" border="0" cellpadding="0" cellspacing="0" width="575">
<tr>
<td align="left" valign="top" width="100%">
<p style="font-size:9px;">
<font color="#000000" face="Verdana, Arial, Helvetica, sans-serif" size="1" style="font-size: 9px; font-family: Verdana, Arial, Helvetica, sans-serif;">
Don't see the images in this e-mail? Please add eblast@KidsPages.org to<br /> your address book or safe senders list.<br />
<br />
You are receiving these bimonthly eBlasts because of your relationship with KidsPages.org.<br />
We will never share our mailing list with anyone. If you do not wish to continue<br />
receiving these announcements, please click <a href="http://kidspages.org/unsubscribe/$email_address">here</a> to unsubscribe.<br />
<br />
&copy; Copyright 2009 Kids Pages Family Media, Inc.
</font>
</p>
</td>
</tr>
</table>
</body>
</html>


EOT;

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

FREE Family Fun Galore!

Go to KidsPages.org to visit your Complete Family Resource for Festivities and Family Fun throughout the Front Range!

EOT;

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

  $mail->Body    = $body;
  $mail->AltBody = $text_body;
  $mail->Subject = "Free Family Fun this April from Kids' Pages";
  $mail->AddAddress( $email_address );


//    echo "NOT sending $count / $numrows to " . $email_address . "<br>";
//    $insertsql = "INSERT INTO `kp_ebook_sent` (`email`) VALUES ( '$email_address' )";
//    $insert_success = MYSQL_QUERY( $insertsql );
//    echo "insert was" . ( $insert_success ? " very" : " NOT" ) . " successful<br /><br />";
    

  if ( !$mail->Send() )
  {
    echo "$count / $numrows : There has been a mail error sending to " . $email_address . "<br>";
  }
  else
  {
    echo "$count / $numrows : Success sending to " . $email_address . "<br>";

    $insertsql = "INSERT INTO `kp_ebook_sent` (`email`) VALUES ( '$email_address' )";
    @MYSQL_QUERY( $insertsql );
  }

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

  echo "<br />";
  echo "### COMPLETE ###<br />";
  echo '### End: ' . date('l jS \of F Y h:i:s A') . "<br />";
?>
