You are here

public function OrphanProcessor::sendOrphanedAccountsMail in Lightweight Directory Access Protocol (LDAP) 8.4

Same name and namespace in other branches
  1. 8.3 ldap_user/src/Processor/OrphanProcessor.php \Drupal\ldap_user\Processor\OrphanProcessor::sendOrphanedAccountsMail()

Send email.

1 call to OrphanProcessor::sendOrphanedAccountsMail()
OrphanProcessor::checkOrphans in ldap_user/src/Processor/OrphanProcessor.php
Check for Drupal accounts which no longer have a related LDAP entry.

File

ldap_user/src/Processor/OrphanProcessor.php, line 213

Class

OrphanProcessor
Locates potential orphan user accounts.

Namespace

Drupal\ldap_user\Processor

Code

public function sendOrphanedAccountsMail() : void {
  $to = $this->configLdapUser
    ->get('orphanedDrupalAcctReportingInbox');
  if (empty($to)) {
    $to = $this->configFactory
      ->get('system.site')
      ->get('mail');
  }
  $siteLanguage = $this->languageManager
    ->getCurrentLanguage()
    ->getId();
  $params = [
    'accounts' => $this->emailList,
  ];
  $result = $this->mailManager
    ->mail('ldap_user', 'orphaned_accounts', $to, $siteLanguage, $params);
  if (!$result) {
    $this->logger
      ->error('Could not send orphaned LDAP accounts notification.');
  }
}