You are here

function _apigee_edge_send_developer_email_verification_email in Apigee Edge 8

Sends a verification email to the developer email that is already taken.

Parameters

\Drupal\Core\Session\AccountInterface $account: The user object of the account being notified. Must contain at least the fields 'uid', 'name', and 'mail'.

string $langcode: (optional) Language code to use for the notification, overriding account language.

Return value

array An array containing various information about the message. See \Drupal\Core\Mail\MailManagerInterface::mail() for details.

See also

\_apigee_edge_existing_developer_mail_tokens()

1 call to _apigee_edge_send_developer_email_verification_email()
apigee_edge_form_user_register_form_developer_email_validate in ./apigee_edge.module
Validates whether the provided email address is already taken on Apigee Edge.

File

./apigee_edge.module, line 673
Copyright 2018 Google Inc.

Code

function _apigee_edge_send_developer_email_verification_email(AccountInterface $account, $langcode = NULL) {
  if (\Drupal::config('apigee_edge.developer_settings')
    ->get('verification_action') === DeveloperSettingsForm::VERIFICATION_ACTION_VERIFY_EMAIL) {
    $params['account'] = $account;
    $langcode = $langcode ? $langcode : $account
      ->getPreferredLangcode();

    // Get the custom site notification email to use as the from email address
    // if it has been set.
    $site_mail = \Drupal::config('system.site')
      ->get('mail_notification');

    // If the custom site notification email has not been set, we use the site
    // default for this.
    if (empty($site_mail)) {
      $site_mail = \Drupal::config('system.site')
        ->get('mail');
    }
    if (empty($site_mail)) {
      $site_mail = ini_get('sendmail_from');
    }
    $mail = \Drupal::service('plugin.manager.mail')
      ->mail('apigee_edge', 'developer_email_verification', $account
      ->getEmail(), $langcode, $params, $site_mail);

    // TODO Should we notify admins about this?
  }
  return empty($mail) ? NULL : $mail['result'];
}