MyBB Community Forums

Full Version: Sending multipm through php script
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,
I have some strange problem with script that send notifications to my users.
Here you have my function:

function send_pw($subject,$message,$toid,$fromid=564)
{
	global $content;
	$subject="[PANEL] ".$subject;
	$message.="
	
	[b]Wiadomosc wygenerowana automatycznie. Prosimy na nia nie odpowiadac.[/b]";
	$pmhandler = new PMDataHandler();
	$pm = array(
            "subject" => $subject,
            "message" => $message,
            "fromid" => $fromid,
            "toid" => array($toid)
        );
	$pm['options'] = array(
            "signature" => 0,
            "disablesmilies" => 0,
            "savecopy" => 0,
            "readreceipt" => 0 
       );

    $pmhandler->set_data($pm);
    if(!$pmhandler->validate_pm())
    {
        debug($pm_errors = $pmhandler->get_friendly_errors());
	}
	else $pminfo = $pmhandler->insert_pm(); 
	return 1;
}

If I execute this function once, it works fine (Send one pm).
But when I try to execute it more than once (different messages, different $toid) script send only one pm (first one).

Is this limitation of mybb?
How can I send more than one different message?

Greetings from Poland,
Mariusz W. czerwony03
MyBB already have function to send pm
https://github.com/mybb/mybb/blob/featur....php#L8085

you can try put $pm['touid'] to array and then run this func for each element

Smile
Same problem when using this function.
Only first message was send.

@Supryk
I can use $pm['touid'] as array but it will send same messages to all recipients and i want to send different.

I think that I should check mybb script for mass mail, because there is something that send customized messages.
$odbiorcy = array(1,2,3);

foreach($odbiorcy as $odbiorca)
{
send_pm(array('subject' => 'Test', 'message' => 'test', 'touid' => $odbiorca ), $sender_uid, true);
}

napisane z palca, jedyne mi w tej chwili przychodzi do glowy
Kod jest w porządku, problem w tym, że po jego wywołaniu zostaje wysłane pw tylko do pierwszej osoby. Pozostałe niestety nie.

Natomiast gdy wysyłam jedno PW ale do wielu osób ('touid'=>array(1,2,3,4)) wszystko jest ok, ta sama wiadomosc laduje w skrzynkach wyznaczonych osób.