Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When views_send actually sends the eMails via cron, there is no $message['id']. If other modules are depending on this ID to be present to do something with those messages (any hook_mail_alter, for example), they'd not be there, which is problematic. I'm thinking they really should be included, should they not?
I hacked views_send.cron.inc to include one for a site I developed. Would be good if this was fixed before the release.
Shawn
Comment | File | Size | Author |
---|---|---|---|
#3 | views_send_cbd_2013-08-08_3.patch | 836 bytes | hansfn |
#2 | views_send_cbd_2013-08-08.patch | 1.09 KB | sdsheridan |
Comments
Comment #1
hansfn CreditAttribution: hansfn commentedI see what you mean. The message ID is generated when drupal_mail is called in _views_send_prepare_mail, but then the module just ignores it. There is no ID field in the views_send_spool table.
I'll look at it, but D6 is generally low priority since D8 is coming closer. (The D7 version is also ignoring the ID, but at least you have hooks do the same as hook_mail_alter.)
Comment #2
sdsheridanWell, here's a patch for the hack I did. It's simplistic, but at least it provides an ID.
Shawn
Comment #3
hansfn CreditAttribution: hansfn commentedThe patch/hack is harmless enough, but I think we are attacking this wrong.
drupal_mail invokes hook_mail_alter and hook_mail. Views Send calls drupal_mail in the function _views_send_prepare_mail and the id is set to "views_send_direct" inside drupal_mail, so this should work for everyone that wants to modify a message. However, you want to do Mime Mail theming. This should have been done by the call to mimemail in the same function, but in that call to mimemail the mailkey is missing - a bug. Please try the minimal patch attached and see if it works. If not, explain what you are trying to do that didn't work with hook_mail_alter/hook_mail.
Comment #4
hansfn CreditAttribution: hansfn commentedSorry, I mixed up this issue with another. My Mime Mail related patch is correct, but not what you were discussing. Anyway, I don't understand why you can't use hook_mail/hook_mail_alter when drupal_mail is called in in the function _views_send_prepare_mail. Doesn't that work?
Comment #5
sdsheridanIt doesn't work because that's called before the message is stored in the views_send_spool table for processing by cron later. Cron then retrieves the messages to actually do the eMailing, but there is now no $key, because it's not stored. So, another scheme for preserving the message key is needed. My solution is definitely a hack, because the original message key is lost and a generic 'views_send' one is added to the message array before drupal_mail_send is called.
Now, why do I need the message key at this point you may ask? The use case is that I'm using MailQ to do a similar thing to what views_send already does with it's own eMails, and I've modified MailQ (https://drupal.org/node/2054317) so that it has the ability to look at the message ID / key and where the user has indicated by way of specifying the message ID, not queue the message. Otherwise, I'd have double queuing of eMails from views_send, which seems rather unnecessary.
Shawn
Comment #6
hansfn CreditAttribution: hansfn commentedNo need to repeat the reason the message ID was missing at that point ;-) I just wanted to know the use case.
Fixed in commit 2626d57. (Mostly identical to your patch.)
Comment #8
ufku CreditAttribution: ufku commentedThe fix is missing for 7.x
It prevents Mandrill to apply a specific template for views_send.
Comment #9
hansfn CreditAttribution: hansfn commentedSorry about the late reply.
I'm onto it - ref #1810254: Compatability with views_send. I expect a quick fix - since it's a one-liner.
Comment #11
hansfn CreditAttribution: hansfn commentedFixed for the D7 version in committed c8350c3 - see link above. Sorry about the delay. (It's the same fix as for D6.)