Since the 3.x branch of Mail System now owns its own MailSystem class, we should try to ensure that the module remains enabled while MailsystemDelegateMailSystem is an available mail class.

Trying to clean up the variable in hook_disable() is probably a non-starter, for the same reasons as explained in #1427612: Variables are not deleted on uninstall of module cause site email to break. Instead, the attached patch uses to hook_system_info_alter() to mark the module as required until the user adjusts the Mail System configuration to the point where MailsystemDelegateMailSystem isn't being used anymore.

mailsystem-prevent_disable.patch990 bytesLes Lim