I have a newsletter (simplenews) being used from time to time and it uses SMTP server to send mail. All other emails from my site should be sent using default interface. How do I do this?

I thought Mail System module could help me with this, but seems I'm doing that wrong thus I can only switch between interfaces, but not assign SMTP to simplenews only and left other using default one. How can I do that?

  • At least for D8 the drupal.org/project/swiftmailer module let's you choose different handlers for different modules.
    – leymannx
    Commented Jan 26, 2017 at 15:46
  • I'm now trying to use Mail System module for that, but it ignores any custom settings I have added. It still changes default mail class, but when i'm adding a new setting for any module, it is being ignored and mail sent by the class set in default field. What am i doing wrong?
    – Andriy
    Commented Nov 4, 2017 at 11:43

1 Answer 1


For D7 you can define a custom mail system using the $conf['mail_system']

$conf['mail_system'] = array('mycustom_module_thekey' => 'MyCustomEmailSystem');

Then you can use the drupal_mail function

drupal_mail('mycustom_module', 'thekey', $email, language_default(), $params, $from);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.