Where hook_mail_alter() is invoked in drupal_mail() we have the $send boolean value in scope, but it's not included in the $message variable that is passed into the mail_alter. It would be helpful in some circumstances to allow users to prevent emails from sending using hook_mail_alter().

This patch provides that functionality by routing the $send value into the $message, and then doing the send check based on the value in the $message after it has run through hook_mail_alter().

CommentFileSizeAuthor
hook_mail_alter_update_send.patch804 bytesmlsamuelson

Comments

dmitrig01’s picture

Status: Needs review » Needs work

+ 'send' -> $send,

=> instead of ->

Please write a test if we have an email testing framework (not sure if we do), if not please attach a test module and please test it yourself :-)

mlsamuelson’s picture

Status: Needs work » Needs review

There are existing tests for the mail system in modules/simpletest/tests/mail.test. I've looked some into creating a test for the mail_alter hook, but I'm new to the test framework and it's not apparent to me how I'd go about testing a hook. I haven't found anything in the docs, and my browsing through the code hasn't helped, either.

I'd be happy to give it a go, but at this point I could use a push in the right direction. :)

pillarsdotnet’s picture

Status: Needs review » Closed (duplicate)