You are here

function email_confirm_build_mail in Email Change Confirmation 7

Same name and namespace in other branches
  1. 6 email_confirm.module \email_confirm_build_mail()

Build and send out the confirmation emails.

1 call to email_confirm_build_mail()
email_confirm_user_presave in ./email_confirm.module
Implements hook_user_presave().

File

./email_confirm.module, line 346
The Email Change Confirmation module.

Code

function email_confirm_build_mail($edit, $account) {
  $params = array();
  $params['account'] = $account;
  $params['new_mail'] = $edit['mail'];
  $params['old_mail'] = $account->mail;
  $params['context']['url'] = url(email_confirm_confirmation_email_url_path($edit['mail'], $account->uid), array(
    'absolute' => TRUE,
  ));
  $default_from = email_confirm_default_confirmation_email_author();
  $from = variable_get('email_confirm_confirmation_email_author', $default_from);

  // To account for case where the variable was stored with an empty string.
  // Make sure a from email was set. Otherwise, use the default.
  if (empty($from)) {
    $from = $default_from;
  }
  $bcc = variable_get('email_confirm_confirmation_email_bcc', '');
  $params['headers'] = array();
  if ($bcc) {
    $params['headers']['Bcc'] = $bcc;
  }
  if ($message['result'] = drupal_mail('email_confirm', 'confirmation_email', $edit['mail'], user_preferred_language($account), $params, $from)) {
    drupal_mail('email_confirm', 'confirmation_original_email', $account->mail, user_preferred_language($account), $params, $from);
    drupal_set_message(t('A confirmation email has been sent to your new email address. You must follow the link provided in that email within 24 hours in order to confirm the change to your account email address.'));
  }
}