You are here

public static function LearningPathAccess::sendMail in Opigno Learning path 3.x

Same name and namespace in other branches
  1. 8 src/LearningPathAccess.php \Drupal\opigno_learning_path\LearningPathAccess::sendMail()

Sends mail.

1 call to LearningPathAccess::sendMail()
LearningPathAccess::notifyUsersByMail in src/LearningPathAccess.php
Prepares and sends emails to users.

File

src/LearningPathAccess.php, line 479

Class

LearningPathAccess
Class LearningPathAccess.

Namespace

Drupal\opigno_learning_path

Code

public static function sendMail($to, $subject, $message, $params = []) {
  $langcode = \Drupal::currentUser()
    ->getPreferredLangcode();
  $mailManager = \Drupal::service('plugin.manager.mail');
  $module = 'opigno_learning_path';
  $key = 'opigno_learning_path_user_subscribe';
  $params['subject'] = $subject;
  $params['message'] = $message;
  $send = TRUE;
  $result = $mailManager
    ->mail($module, $key, $to, $langcode, $params, NULL, $send);
  return $result['result'];
}