View Full Version : sending mail to multiple users

01-28-2007, 10:59 PM
Hey, i have an online game, where you can send private messages to one another... i want to alter it so that you can put in the 'To' form: user1, user2 and it would send to both users.

my code now:

$username_to = $_POST['a_username_to'];

$result1 = mysql_query("SELECT * FROM userinf WHERE username='$username_to'", $db);

$retval1 = mysql_fetch_array($result1);

$subject = trim(strip_tags($_POST['subject']));

$message = strip_tags($_POST['message']);

if(!strlen($subject)) { $subject = "(none)"; }

if(!strlen($message)) { $err .= "No message supplied. "; }

$result = mysql_query("SELECT bactiv FROM userinf WHERE username='$username_to'", $db);

if(!mysql_num_rows($result)) { $err .= "Player not found. "; }

else {

$retval = mysql_result($result,'bactiv');

if($retval!='1') { $err .= "Player is blocked, and cannot recieve messages. "; }

if(strlen($err)<3) {

mysql_query("INSERT INTO mailinf(userfrom,rtime,username_to,subject,message) VALUES ('".$userinf['username']."','".time()."','$username_to','$subject','$message') ", $db);

Please help ASAP, thanks

01-29-2007, 02:18 AM
can someone please help me... i need this badly

01-29-2007, 05:14 PM
I don't even see a call to the mail() function in the code you pasted.

01-29-2007, 07:20 PM
@ Fumigator:

I think he is talking about PMs like on Forums, not actually emails.


If you get the TO-string as a POST variable, try using regular expressions or explode() to get the names of the users. From that you would have to write a look-up function that would look up the ID of the users the PM should be sent to. Then just add multiple entries into the DB with that message (for, foreach loop)