-5

I using PHPmailer, Mail System module to sent mail.

function demomail_mail($key, &$message, $params) {
  $options = array(
    'langcode' => $message['langcode'],
  );

  switch ($key) {
    case 'create_article':
        $message['format'] = 'text/html';
     $message['headers']['Content-Type'] = SWIFTMAILER_FORMAT_HTML;
        $message['from'] = \Drupal::config('system.site')->get('mail');
        $message['subject'] = t('Article created: @title', array('@title' => $params['node_title']), $options);
        $text[] = $params['message'];
         $message['body'] = array_map(function ($text) {
    return Markup::create($text);
  }, $text);
  break;
  }
}

closed as unclear what you're asking by Jaypan, MrD, leymannx, Kevin, mradcliffe Jan 11 at 12:56

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • It would be useful to know if you use Drupal 7 or 8. On a Drupal 7 project, we used the Rules module to send e-mails on node creations. You can configure it via the admin UI. If you have a SMTP server available, I would suggest to send e-mails via the STMP server instead of sending them directly from the server (often gets flagged as spam). Swiftmailer works great for SMTP mails. – Orlando Jan 11 at 8:41
  • I am using drupal 8. How can I send mail include css. I use Swift Mailer drupal 8 to send mail – Anh Vũ Jan 11 at 8:58
  • What doesn't work? Please update your question for clarification. – leymannx Jan 11 at 10:34

Browse other questions tagged or ask your own question.