While I'm waiting on a response to #607914: API question on destinations for multiple sends I've moved ahead with my module using a kludgy loop that calls messaging_message_send_user(). I know this is ugly and not the preferred way of doing this, but I need to keep rolling with this project, so it's a temporary hack. In any event, here's the meat of the code, largely pulled from code I found here and from notifications.module:

$subscribers is an array containing complete $user objects, each one is a person who has flagged content (using Flags).

<?php
	foreach($subscribers as $key => $account){
		$message = array();

		$sending_method = messaging_method_default($account);
		$message['subject'] = messaging_message_part('content-subscriptions-event', 'subject', $sending_method );
		$message['body'] = messaging_message_part('content-subscriptions-event', 'main', $sending_method);
		
		messaging_message_send_user($account, $message, $sending_method, 1);
		unset($message);
	}
?>

This results in a complete row in messaging_store for each outgoing message - all looks good there. It shows with 'sent' as '0' until I force a cron run, and then it shows a timestamp, indicating it has been sent. In the watchdog entry after sending, the outgoing message looks exactly as I'd expect.

Here's what I see in the messaging_store:

mqid 	uid 	sender 	method 	destination 	subject 	body 	params 	created Descending 	sent 	cron 	queue 	log
201 	1 	1 	privatemsg 	user:1 	Event notification  	<p> A item to which you are subscribed has been updated </p>
	a:1:{s:12:"destinations";a:1:{i:0;s:1:"1";}} 	1255904179 	1255904222 	0 	0 	1

202 	13 	1 	mail 	user:13 	Event notification for [user] from [site-name] 	A item to which you are subscribed has been updated 	a:1:{s:12:"destinations";a:1:{i:0;s:21:"my@domain.com";}} 	1255904179 	1255904222 	0 	0 	1

...and here's the watchdog entry:

Message for my@domain.com: Event notification
Message body:

A item to which you are subscribed has been updated

In my test case, I'm sending to two users: one via email and one via privatemsg. obviously, i've replaced my real address with a dummy one for this post.

So by all indications, the messages go out. But no message ever shows up either via email or in the messages queue for the user who should be getting a private message. I see no errors in watchdog, just confirmation of a successful send. The messages, however, just vanish into a black hole.

I should also note that the privatemsg module works fine - we've been using it for months with no issues. So we know the messaging framework is ok. I've tested this within the last 10 minutes just to be sure. Notifications also works, but we're not using it because it's overkill for our purposes. it is installed, however.

any ideas?

Comments

friolator’s picture

Status: Active » Closed (fixed)

hoo boy. long night last night.

Debug was on, so messages weren't going out. Amazing what a good night's sleep will make obvious when you're debugging something.

sorry for the interruption...