PHP Code:
<?
require("backend/functions.php");
dbconn(false);
loggedinonly();
if (!$CURUSER || $CURUSER["control_panel"]!="yes"){
show_error_msg("Error","Sorry you do not have the rights to access this page!",1);
}
if (!defined('PHP_EOL')) define ('PHP_EOL', strtoupper(substr(PHP_OS,0,3) == 'WIN') ? "\r\n" : "\n");
if ($_POST) {
set_time_limit(0);
$headers = "From: $site_config[SITEEMAIL]".PHP_EOL;
$headers .= "Return-Path: $site_config[SITEEMAIL]".PHP_EOL;
$headers .= "Content-type: text/plain; charset=ISO-8859-1; format=flowed".PHP_EOL;
$headers .= "X-Mailer: PHP".phpversion().PHP_EOL;
$classes = $_POST['classes'];
$subject = $site_config["SITENAME"]." - ".(get_magic_quotes_gpc()?stripslashes($_POST["subject"]):$_POST["subject"]);
$body = (get_magic_quotes_gpc()?stripslashes($_POST["body"]):$_POST["body"]);
$body .= "\n\n\n\nNote: this is a mass email and has been sent to ALL members.Visit http://extremlymtorrents.ws/account-recover.php for more information! ";
if (empty($subject) || empty($body)) show_error_msg("Error","Don't leave subject or body blank.<BR><BR><a href='?' onclick='history.back()'>Click here</a> to try again.");
if (count($classes) < 1) show_error_msg("Error","You MUST select a user class.<BR><BR><a href='?' onclick='history.back()'>Click here</a> to try again.");
$classes = implode(",", $classes);
$res = mysql_query("SELECT email FROM `users` WHERE status='confirmed' AND enabled='yes' AND class IN ($classes)") or die(mysql_error());
if (mysql_num_rows($res) == 0)
show_error_msg("Error", "No users found for that class.");
while ($row=mysql_fetch_array($res)) {
if (!mail("Multiple recipients <$site_config[SITEEMAIL]>", $subject, $body, $headers."Bcc: $row[email]".PHP_EOL))
show_error_msg("Failed", "Mail didn't get sent.");
}
show_error_msg("Success", "Mail sent");
die;
}
stdhead("Mass Email");
begin_frame("Mass Email","left");
$r = mysql_query("SELECT group_id, level FROM groups ORDER BY group_id ASC") or die(mysql_error());
$i = 0;
while($rr=mysql_fetch_row($r)) {
$i++;
$classboxes .= "<input type='checkbox' name='classes[]' value='$rr[0]'>".htmlspecialchars($rr[1])." ";
if ($i % 3 == 0)
$classboxes .= "";
}
print <<<EOD
<form method="post" action="?">
<table class=xty width=1030>
<tr>
<td align=right>Subject:</td><td><input cols=155 type=text name=subject></td>
</tr>
<tr>
<td align=right valign=top>Body:</td><td><textarea cols=200 rows=10 name=body></textarea></td>
</tr>
<tr>
<td align=right valign=top>User classes to send to:</td><td>$classboxes</td>
</tr>
<tr>
<td colspan=2><center><input type="Submit" value="Send"/></center></td>
</tr>
</table>
</form>
EOD;
end_frame();
stdfoot();
?>
After sending i recive
Failed
Mail didn't get sent.