Specifications

LISTING 28.16 Continued
mysql_result($result, $i, 1));
}
}
// add HTML and text to the mimemail object
$mail->add_html($html, $text);
// note that we build and encode the message here outside the loop,
// not repeatedly inside the loop
$mail->build_message();
if($status == ‘STORED’)
{
//send the HTML version of the message to administrator
$mail->send(get_real_name($admin_user), $admin_user,
$from_name, $from_address, $subject);
//send the text version of the message to administrator
mail(get_real_name($admin_user).” <”.$admin_user.”>”, $subject,
$text, “From: $from_name <$from_address>”);
echo “Mail sent to $admin_user”;
$query = “update mail set status = ‘TESTED’ where mailid = $mailid”;
if(db_connect())
{
$result = mysql_query($query);
}
echo “<p>Press send again to send mail to whole list.<center>”;
display_button(‘send’, “&id=$mailid”);
echo “</center>”;
}
else if($status == ‘TESTED’)
{
//send to whole list
$query = “select subscribers.realname, sub_lists.email,
subscribers.mimetype
from sub_lists, subscribers
where listid = $listid and
sub_lists.email = subscribers.email”;
if(!db_connect())
return false;
Building Practical PHP and MySQL Projects
P
ART V
706
34 7842 CH28 3/6/01 3:46 PM Page 706