sysadmin42
Technical User
- May 6, 2005
- 138
I have a script where you first select the users (from the db) that you want to send a message to, next page you write the message, and then click send and it goes out to everyone you selected. It only seems to be sending to one or two recipients and it seemed to work fine for a while.
The odd thing is that when it writes the log (function write_log() below) all the recipients are listed.
Any thoughts?
Here's the code:
The odd thing is that when it writes the log (function write_log() below) all the recipients are listed.
Any thoughts?
Here's the code:
Code:
//variables from previous pages
//these are used just in case the user hits the back button
$_SESSION['tmp_subject']=$_POST['subject'];
$_SESSION['tmp_message']=$_POST['message'];
$_SESSION['tmp_recipients']=$_POST['recipients'];
if ($_POST['subject']=="" || $_POST['message']=="") header("Location: emailer2.php?v2e=1");
unset($_SESSION['tmp_subject']);
unset($_SESSION['tmp_message']);
unset($_SESSION['tmp_recipients']);
//emailer
$option['other_email']=1; //take this out later and add to user options
$server_email_limit=999;
$subject=str_replace(" ","",stripslashes(strip_tags(unhtmlspecialchars($_POST['subject']))));
$msg=str_replace(" ","",stripslashes(strip_tags(unhtmlspecialchars($_POST['message']))));
$msg.="\n\n\n--------This message sent courtesy of BNI Connection. To log on, visit [URL unfurl="true"]www.bniconnection.com";[/URL]
$message="";
$mailheaders="From: {$_SESSION['firstname']} {$_SESSION['lastname']} <{$_SESSION['my_email']}>\n";
$mailheaders.="Reply-To: {$_SESSION['my_email']}";
//get receipient emails
$sql_email="SELECT id,email FROM members WHERE id IN ({$_POST['recipients']}) AND active='1' LIMIT 0,$server_email_limit";
$result_email=@mysql_query($sql_email,$conn) or die(mysql_error());
//send to each recipient
while ($emailer=mysql_fetch_array($result_email)) {
$option=get_profile_options($emailer['id'],$conn);
$recipient=$emailer['email'];
mail($recipient,$subject,$msg,$mailheaders);
$message.="user emailed: $recipient<br>";
}
write_log($_SERVER['PHP_SELF'],"Email Sent.<br>".$message,$conn);