Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: send mass email


r-a-y
Keymaster

@r-a-y

@jeremyltn

Just took a quick look at the code, it’s not great to add all the recipients to the one message because when you view the message in BP, you’ll see all the user IDs attached to that message.

To remedy this, use a foreach loop for the $user_ids array.

Also, implement some type of delay for every x amount of messages sent.

Check out the sleep() function.

eg.

$s = 0; // sent messages counter
foreach ($user_ids as $user_id) {
if($user_id == "1") continue; // do not send message to yourself!

messages_new_message( array('sender_id' => 1, 'subject' => $subject, 'content' => $body, 'recipients' => $user_id) );

$s++;

if ( $s % 50 == 0 )
sleep(10); // to help server load, delay 10 seconds for every 50 messages sent
}

Skip to toolbar