Hi,

I am currently using the Broadcast facility offered by og_notifications, and I would like to be able to have the "From" address be filled in with the current user's address. Currently all the broadcast messages have the site address in their "From" field. Is there an way to set this? (or at least can you point me to some hook to implement/function to theme to change the From address of the broadcast message?)

Thanks.

Files: 
CommentFileSizeAuthor
#9 og-broadcast.patch1.85 KBJody Lynn

Comments

Status:Active» Fixed

hook_mail_alter is the code for this.

Category:feature» bug
Status:Fixed» Active

Actually that sounds like a bug. Might be fixed in 2.x branch.

I've installed the latest dev releases for the og(6.x-2.x-dev, May 6th), messaging(6.x-2.x-dev, April 30th) and notifications(6.x-2.x-dev, April 30th) modules, and this problem is still there, the broadcast message is sent with the site's mail as a "From" address rather than the email of the currently logged in user.

Version:6.x-1.3» 6.x-2.x-dev

The problem seems to be that notifications_lite_send doesn't keep track of a sender. We may need to push this as a feature request to notifications.

Project:Organic groups» Notifications
Component:og_notifications» Code

As this wasn´t added to the notifications queue, I´ll change the project, to avoid creating duplicate issue posts.

Category:bug» support
Status:Active» Postponed (maintainer needs more info)

I thought og handled 'From' field for messages it sends. Please clarify whether this is a bug, feature request, or what.

Hi Jose

og_broadcast_form_submit creates a message with a 'from' field and og_notifications_og then uses notifications_lite_send but notifications_lite_send doesn't seem to take a parameter for 'from'. I'm not sure if og is using notifications incorrectly or if notifications_lite could need adjustment.

Project:Notifications» Organic groups
Component:Code» og_notifications
Status:Postponed (maintainer needs more info)» Needs review

StatusFileSize
new1.85 KB

Sending this back to og with a patch. I now think it's og's bug because notifications is meant to handle system emails and does not worry about custom From: fields.

This patch uses standard drupal mail for og broadcast emails and includes the corrent 'from' value.

Category:support» bug
Status:Needs review» Needs work

The patch effectively is self-defeating as the idea of using notifications-lite is to allow the use of the main notifications module (and drupal_mail as the fall-back) in delivering the message.

I now think it's og's bug because notifications is meant to handle system emails and does not worry about custom From: fields. Is there an issue where the notifications devs allude to this?

IIRC, this was working fine at one point. If it's not working now, it's an OGN/notifications bug.

-K

Yeah, the patch is really just a cheap workaround.

I tried the patch but emails are still coming from the sitewide email address for broadcasts.
Tried it with and without the mimemail module enabled.

Moshe,

Using hook_mail_alter seems like the most appropriate short-term fix but I am having trouble identifying just broadcast messages within that hook.

I setup a simple module providing hook_mail_alter for this purpose, and I do see the messages with it. However, I am not sure there is a way to target broadcast messages independent of all messages sent with the Notifications module.

The $message['id'] is "messaging_message-notifications" which I think is shared by everything that Notifications sends. I tried to attempt a small hack of og_notifications.module to add an identifying param to the notifications_lite_send call in og_notifications_og, however for some reason the only param I get in my hook_mail_alter is the 'from' param.

I am resorting to doing text matching against the $message['body'] for text specific to the broadcast template. If found I'll then adjust the from field and corresponding headers. This just feels really ugly and is prone to break as soon as our template changes.

Since you suggested h_m_a, is there a good way of using it to target just these broadcast messages?

Thanks,
Matt

Version:6.x-2.x-dev» 6.x-2.1

i found the issue, its a bug in notifications light, which OG uses to send notifications, im changing the issue there

first you need to configure notifications at admin/messaging/notifications
Notifications Sender: Full user data (User name and available user information)

then apply the change below (patch was run on an older version, basically you need to comment out the uid field in the $event array in notifications_lite_add_to_queue(), in file notifications/notifications_lite/notifications_lite.module)
leaving uid out will auto-set its value to the current's user uid notifications_event(), and use it as the sender as it should, the above configuring decides this..

<?php
--- notifications/notifications_lite/notifications_lite.module_dist     2010-07-18 16:08:57.000000000 -0400
+++ notifications/notifications_lite/notifications_lite.module  2010-07-18 16:08:16.000000000 -0400
@@ -85,7 +85,7 @@ function notifications_lite_add_to_queue
  
// Build and store simple event
  
$event = array(
    
'module' => 'notifications',
-   
'uid' => 0,
+
//    'uid' => 0,
    
'oid' => $uid,
    
'type' => 'lite',
    
'action' => $action,
?>

p.s. this covers only the first if in notifications_lite_send(), the 'notifications' case which is what i had to fix
for 'messaging' you need to set something like $message['params']['mail']['from'] = 'User Name '; to cover both cases where mimemail and drupal_mail are used.. drupal_mail uses only this value, where as mimemail i think supports building it from the user account, kinda inconsistent, see messaging_mail_prepare() in messaging/messaging.mail.inc, and messaging/messaging_mail/messaging_mail.module and messaging/messaging_mime_mail/messaging_mime_mail.module for more info.. i didnt look into phpmailer, so theres yet another choice
and for the last if, where drupal mail is used directly, it just needs the $from parameter set, same format as $message['params']['mail']['from'] so that can be reused.. i guess a global $user and assemble name and email, use the theme_(?) call to account for realname module (i dont have time to fix and check this now.. sorry)
hope someone will find this useful

Project:Organic groups» Notifications
Version:6.x-2.1» 6.x-2.2
Component:og_notifications» Code

I just want to comment that the fix in #14 worked perfectly - but be careful to ONLY comment out the line on #85! Seems like a Notifications module issue in not respecting the declared 'from' address from OG.

I don't want my Group admins setting an email address. Absolutely bad idea. They can set anything they want. Not good.

yes #14 works but is this a good approach to do ?