1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
| include('Mail.php');
include('Mail/mime.php');
$message = new Mail_mime("\r\n");
$textfilename = "archive/$listid/$mailid/text.txt";
$tfp = fopen($textfilename, "r");
$text = fread($tfp, filesize($textfilename));
fclose($tfp);
$htmlfilename = "archive/$listid/$mailid/index.html";
$hfp = fopen($htmlfilename, "r");
$html = fread($hfp, filesize($htmlfilename));
fclose($hfp);
$message->setTXTBody($text);
$message->setHTMLBody($html);
$query = "select path, mimetype from images where mailid = $mailid";
if(db_connect())
{
$result = mysql_query($query);
if(!$result)
{
echo '<p>Unable to get image list from database.';
return false;
}
$num = mysql_numrows($result);
for($i = 0; $i<$num; $i++)
{
$imgfilename = "archive/$listid/$mailid/".mysql_result($result, $i, 0);
$imgtype = mysql_result($result, $i, 1);
$message->addHTMLImage($imgfilename, $imgtype, $imgfilename, true);
}
}
$body = $message->get();
$from = '"'.get_real_name($admin_user).'" <'.$admin_user.'>';
$hdrarray = array(
'From' => $from,
'Subject' => $subject);
$hdrs = $message->headers($hdrarray);
$sender =& Mail::factory('mail');
if($status == 'STORED')
{
$sender->send($admin_user, $hdrs, $body);
mail($admin_user, $subject, $text, 'From: "'.get_real_name($admin_user).'" <'.$admin_user.">");
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 sub_lists.userid,
user.iduser, user.email
from sub_lists, user
where listid = $listid and
sub_lists.userid = user.iduser";
if(!db_connect())
return false;
$result = mysql_query($query);
if(!$result)
echo '<p>Error getting subscriber list';
while($val=mysql_fetch_array($result))
{
mail($val["email"], $subject, $text,
'From: "'.get_real_name($admin_user).'" <'.$admin_user.">");
} |
Partager