You are here

function _user_import_send_email in User Import 6.2

Same name and namespace in other branches
  1. 8 supported/user_import.inc \_user_import_send_email()
  2. 5.2 supported/user_import.inc \_user_import_send_email()
  3. 5 supported/user_import.inc \_user_import_send_email()
  4. 6.4 supported/user_import.inc \_user_import_send_email()
  5. 7.3 supported/user_import.inc \_user_import_send_email()
  6. 7 supported/user_import.inc \_user_import_send_email()
  7. 7.2 supported/user_import.inc \_user_import_send_email()
1 call to _user_import_send_email()
user_import_user_import_after_save in supported/user_import.inc
Implementation of hook_user_import_after_save().

File

supported/user_import.inc, line 38

Code

function _user_import_send_email($account, $password, $profile, $subject, $body, $format, $css, $subscribed) {
  global $base_url;

  // All system mails need to specify the module and template key (mirrored from
  // hook_mail()) that the message they want to send comes from.
  $module = 'user_import';
  $key = 'welcome';

  // Specify 'to' and 'from' addresses.
  $to = $account->mail;
  $from = variable_get('site_mail', NULL);
  $params = array(
    '!username' => $account->name,
    '!uid' => $account->uid,
    '!site' => variable_get('site_name', 'drupal'),
    '!login_url' => user_pass_reset_url($account),
    '!password' => $password,
    '!uri' => $base_url,
    '!uri_brief' => drupal_substr($base_url, drupal_strlen('http://')),
    '!mailto' => $account->mail,
    '!date' => format_date(time()),
    '!login_uri' => url('user', array(
      'absolute' => TRUE,
    )),
    '!edit_uri' => url('user/' . $account->uid . '/edit', array(
      'absolute' => TRUE,
    )),
    'subject' => $subject,
    'body' => $body,
    'email_format' => $format,
    'css' => $css,
  );
  _user_import_publication_email($params, $account, $subscribed, $format);

  // import info to profile
  if (module_exists('profile') && is_array($profile)) {
    $profile_name = _user_import_profile('fid', 'name');
    foreach ($profile_name as $fid => $field_name) {
      $params['!' . $field_name] = $profile[$fid];
    }
  }
  $language = user_preferred_language($account);

  // Whether or not to automatically send the mail when drupal_mail() is
  // called. This defaults to TRUE, and is normally what you want unless you
  // need to do additional processing before drupal_mail_send() is called.
  $send = TRUE;
  $sent = drupal_mail($module, $key, $to, $language, $params, $from, $send);
  return;
}