You are here

protected function application_manager::send_email in Apply for role 8

Helper function to send a generic email to respective parties during application handling.

3 calls to application_manager::send_email()
application_manager::approve_application in src/application_manager.php
application_manager::create_application in src/application_manager.php
Create an application.
application_manager::deny_application in src/application_manager.php

File

src/application_manager.php, line 253
Contains two classes.

Class

application_manager
Application manager object used for performing any tasks relating to applications.

Namespace

Drupal\apply_for_role

Code

protected function send_email($to, $subject, $body, $replacements = array()) {
  $mailManager = \Drupal::service('plugin.manager.mail');
  $langcode = \Drupal::currentUser()
    ->getPreferredLangcode();
  foreach ($replacements as $replacement => $value) {
    $body = str_replace($replacement, $value, $body);
  }

  // Send email, capture result.
  $result = $mailManager
    ->mail('apply_for_role', 'apply_for_role', $to, $langcode, array(
    'to' => $to,
    'subject' => $subject,
    'body' => $body,
  ), NULL, TRUE);
}