You are here

function _scn_send_mail in Simple Comment Notify 8

Send mail common function.

1 call to _scn_send_mail()
scn_entity_insert in ./scn.module
Implements hook_entity_insert().

File

./scn.module, line 39
Main file for the scn module.

Code

function _scn_send_mail($to, $subject, $params) {
  if (\Drupal::service('email.validator')
    ->isValid($to)) {
    $mailManager = \Drupal::service('plugin.manager.mail');
    $langcode = \Drupal::currentUser()
      ->getPreferredLangcode();
    $mailManager
      ->mail('scn', 'new_comment', $to, $langcode, $params, NULL, TRUE);
    \Drupal::logger('Simple Comment Notify')
      ->notice(t('Sent eMail notification for comment with subject "@subject"
    to the site administrator eMail address :siteAdministratorEmailAddress', [
      '@subject' => $subject,
      ':siteAdministratorEmailAddress' => $to,
    ]));
  }
}