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
Comment | File | Size | Author |
---|---|---|---|
#7 | different-keys-and-added-parameters-1266528-7.patch | 1.21 KB | joey-santiago |
Comments
Comment #1
gregglesMakes sense to me. Can you post this as a patch?
Comment #2
nk_ CreditAttribution: nk_ commentedHi,
thanks for prompt response!
Here is the patch attached.
Comment #3
gregglesThanks. Updating to better status.
Comment #3.0
gregglestypos
Comment #4
joey-santiago CreditAttribution: joey-santiago commentedI have the same issue on version 7.x-1.2. Should i port it to 7?
Comment #5
gregglesYes please.
Comment #6
gregglesCheck the dev first, please.
Comment #7
joey-santiago CreditAttribution: joey-santiago commentedProbably 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.