I have installed and configured https://www.drupal.org/project/smtp module sending test email works fine, but when sending email with code nothing is sent and also no log in drupal (I have enabled debugging)

    $ownerEmail = '[email protected]';
    $subject = 'update';
    $msg = 'You case has been updates';

1 Answer 1


mail() is a PHP function, that will never use SMTP.

You need to use the drupal mail manager and its mail function. See https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Mail%21MailManager.php/function/MailManager%3A%3Amail/8.4.x and the example code ther.

  • According to the module mentioned in the question, it bypass the mail() and use smtp! Jan 30, 2018 at 2:05
  • If you use the actual drupal mail API yes. It can't bypass anything if you call mail() yourself, that's not possible.
    – Berdir
    Jan 30, 2018 at 8:20

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.