Sorry if that I marked this as "bug report", it is not so really, but again not really feature request...

Is it possible to have different $keys in drupal_mail functions that happens twice in the code:

function _comment_notify_mailalert($comment) {

  // ...

  drupal_mail('comment_notify', 'comment_notify_mail', $author->mail, $language, $message);

  // ...

  drupal_mail('comment_notify', 'comment_notify_mail', $mail, $language, $message);

}

I see that one mail is to author of node post and the other one is for the commenter. However they have the same identifier 'comment_notify_mail' and therefore it is not possible to manipulate with each of them separately on hook_mail_alter. There, they having the same $message['id']
I don't see way how to "alter" on only one of them, for instance on one that goes to post author.

To make better picture with example, I have situation where nodes (main post) have "additional authors" that are userreference CCK fields. I want to put their email addresses as CC in $headers array. Of course I don't want CC when there goes mail to commenter. I tried quite some tricks on hook_mail_alter but couldn't get it. On the other hand it was fairly easy once I changed $key, second argument in second drupal_mail call from 'comment_notify_mail' to 'comment_notify_commenter'.

Is there a particular reason why they must have the same name/key?

Also, is there maybe a way to utilize $sent_to[] variable that I am seeing in the same function.

Thanks.

+nk

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

greggles’s picture

Makes sense to me. Can you post this as a patch?

nk_’s picture

Version: 6.x-1.6 » 6.x-1.5
FileSize
624 bytes

Hi,

thanks for prompt response!
Here is the patch attached.

greggles’s picture

Category: bug » feature
Status: Active » Needs review

Thanks. Updating to better status.

greggles’s picture

Issue summary: View changes

typos

joey-santiago’s picture

Version: 6.x-1.5 » 7.x-1.2

I have the same issue on version 7.x-1.2. Should i port it to 7?

greggles’s picture

Yes please.

greggles’s picture

Check the dev first, please.

joey-santiago’s picture

FileSize
1.21 KB

Probably it would also be useful to add the nid and comment id as parameters so that it would be easier for a hook to know where the mail is triggered from?

See patch attached.