If you want to (automatically) send a PM to a user, you can use the Class vB_Datamanager_PM.
This class makes sure that all values are correct, handles quota for the recipients, notification eMails, etc.
Example
PHP Code:
// create the DM to do error checking and insert the new PM
$pmdm =& datamanager_init('PM', $vbulletin, ERRTYPE_ARRAY);
$pmdm->set('fromuserid', 1234);
$pmdm->set('fromusername', 'Welcome-Bot');
$pmdm->set('title', 'Welcom to our Forums');
$pmdm->set('message', "Hello\nI am a Bot and would like to give you a warm welcome :)");
$pmdm->set_recipients('newuser', $botpermissions);
$pmdm->set('dateline', TIMENOW);
If anything goes wrong you can check for errors using
PHP Code:
$pmdm->errors
This is an erray containing the errors.
If everything is OK
PHP Code:
$pmdm->save();
This will send a PM to user newuser telling him
Quote:
Hello.
I am a Bot and would like to give you a warm welcome
The message will appear to be coming from User Welcom-Bot (Userid 1234).
$botpermissions must be the permissions for the sending user, but can just be empty.
If you want to send PMs no matter if the PM box of the recipient is full or not:
PHP Code:
$botpermissions['adminpermissions'] = 2;
If you want, you can set other options as well ($pmdm->set_info(...)):
forward = 1/0 if this is a forwarded PM, Default=0
savecopy = 1/0 to keep a copy if the PM in outbox, Default=0
receipt = 1/0 to request a read-receipt, Default=0
parentpmid = ID of the PM you are responding to (if applicable)
Furthermore you can specify ($pmdm->set(...)):
iconid = ID of the message icon the PM should carry, Default=0
showsignature = 0/1 Whether the signature should be shown or not, Default=0
showsmilie = 0/1 Wheter smilies should be parsed or not, Default=1
For multiple receipients just use user1;user2;useer3.
This How-To is (C) 2005 by KirbyDE and you are not allowed to redistribute it in any way without my explicit consent.
Are you wanting to bulk email members based on a cron? If so the only thing I believe you need to do would be to figure out what you needed to populate when the cron is run (ie - subject, body, etc.)
I guess I'm confused as to why you are doing this with a cron. If you can provide some background it will give me a better idea of how it might be done.
As to the cron itself. How are you verifying that it is being run correctly? Is there some type of output being generated?
Whats wrong here? I think it worked before now all of a sudden doesnt... (I think) :cross-eyed:
Wow, i'm having the identical error message which just started today as well, I wonder whats going on here... and I mean identical Is there a way to get the script to echo the error? return $pmdm->errors; ? I have that in my cron script, but when i run it in the task manager i get no text echoed, maybee another way so that we can diagnose this problem
Its printing out CMUrick twice and I have no idea why. But its working kinda...
jwocky: You need the code in this post I think to grab names and put em in an array, then you will get a different output in your tests.
Ok, i imploded the array $pmdm->errors in the same way you did above and got it to spit out the error code, turns out in my case, the user set to recieve the PM had his inbox full! argh.