You are here

function _simplenews_set_from in Simplenews 7.2

Same name and namespace in other branches
  1. 6.2 includes/simplenews.mail.inc \_simplenews_set_from()
  2. 6 simplenews.module \_simplenews_set_from()
  3. 7 includes/simplenews.mail.inc \_simplenews_set_from()

Build formatted from-name and email for a mail object.

Return value

Associative array with (un)formatted from address 'address' => From address 'formatted' => Formatted, mime encoded, from name and address

3 calls to _simplenews_set_from()
simplenews_confirmation_send in ./simplenews.module
Send a confirmation mail.
simplenews_confirmation_send_combined in ./simplenews.module
Send collected confirmations.
simplenews_request_hash_submit in includes/simplenews.subscription.inc
Request new hash form submit callback.

File

includes/simplenews.mail.inc, line 662
Simplenews email send and spool handling

Code

function _simplenews_set_from() {
  $address_default = variable_get('site_mail', ini_get('sendmail_from'));
  $name_default = variable_get('site_name', 'Drupal');
  $address = variable_get('simplenews_from_address', $address_default);
  $name = variable_get('simplenews_from_name', $name_default);

  // Windows based PHP systems don't accept formatted email addresses.
  $formatted_address = drupal_substr(PHP_OS, 0, 3) == 'WIN' ? $address : '"' . addslashes(mime_header_encode($name)) . '" <' . $address . '>';
  return array(
    'address' => $address,
    'formatted' => $formatted_address,
  );
}