function email_confirm_build_mail in Email Change Confirmation 6
Same name and namespace in other branches
- 7 email_confirm.module \email_confirm_build_mail()
Build and send out the confirmation email to the user's current and proposed new email address.
1 call to email_confirm_build_mail()
- email_confirm_user in ./
email_confirm.module - Implementation of hook_user().
File
- ./
email_confirm.module, line 228
Code
function email_confirm_build_mail($edit) {
global $user;
$params = array();
$params['account'] = $user;
$timestamp = time();
$pass = $edit['pass'] ? md5($edit['pass']) : $user->pass;
$hash = email_confirm_user_email_rehash($pass, $edit['mail']);
$params['context']['url'] = url('user/change-mail/' . $user->uid . '/' . $timestamp . '/' . $edit['mail'] . '/' . $hash, array(
'absolute' => TRUE,
));
if (module_exists('smtp') && variable_get('smtp_from', '') != '') {
$default_from = $smtp_from;
}
else {
$default_from = variable_get('site_mail', ini_get('sendmail_from'));
}
$from = variable_get('email_confirm_confirmation_email_author', $default_from);
$bcc = variable_get('email_confirm_confirmation_email_bcc', '');
$params['context']['subject'] = email_confirm_mail_text('email_confirm_confirmation_email_subject');
$params['context']['body'] = email_confirm_mail_text('email_confirm_confirmation_email_body');
$params['headers'] = array();
if ($bcc) {
$params['headers']['bcc'] = $bcc;
}
if ($message['result'] = drupal_mail('email_confirm', 'user_change_mail', $edit['mail'], user_preferred_language($user), $params, $from)) {
$params['context']['body'] = email_confirm_mail_text('email_confirm_confirmation_original_email_body');
drupal_mail('email_confirm', 'user_change_mail_original', $user->mail, user_preferred_language($user), $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.'));
}
}