drupal_mail_send() checks the smtp_library variable, and if that file exists, it is loaded and used instead of drupal's default mail handling routines. Contrib modules are expected to set this variable to their own library if they provide one.

The problem is trusting contrib modules to properly remove this variable when disabled or uninstalled. If they don't, Drupal will silently continue to use a disabled module's mail handling routines, this is bad. This effect can only be removed by completely deleting the problem module out of your codebase (so the include file doesn't exist anymore, and Drupal will revert to default mail routines).

drupal_mail_send() should check to make sure they module that owns the include file is also enabled before inclusion. If the module is disabled, use the default mail routines.

This bug is well documented and remains unfixed in Mimemail module #456260: WSOD: smtp_library variable is not removed when mimemail has been disabled, but it would be good to have a safety check against all misbehaving contrib modules.

Comments

kscheirer’s picture

Title: Documentation problem with drupal_mail_send » drupal_mail_send includes libraries from disabled/uninstalled modules

fixed title - preview button seems to have reset it?

ChrisRut’s picture

:subscribe:

kenorb’s picture

+1

mitchmac’s picture

I don't know how we could determine which module has set the variable. Parsing the variable to determine the module name from the filepath only works if drupal_mail_wrapper is defined in the module's own directory structure (wouldn't be the case if referencing an outside library or a module dependency). Adding a new variable or altering smtp_library to keep track of the enabling module would still require proper module implementation right?

Maybe inspect the return from drupal_mail_wrapper? That's tough though because we don't know what to expect and I suspect some of the mail rerouting/altering modules may do some of their magic with this function.

kenorb’s picture

Version: 6.x-dev » 7.x-dev
Issue summary: View changes
Status: Active » Fixed

Mail system has been rewritten in Drupal 7, so marking as fixed in D7 as `smtp_library` doesn't exist anymore.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.