You are here

function mandrill_get_to in Mandrill 8

Same name and namespace in other branches
  1. 6 mandrill.mail.inc \mandrill_get_to()
  2. 7.2 mandrill.module \mandrill_get_to()
  3. 7 mandrill.module \mandrill_get_to()

Helper to generate an array of recipients.

Parameters

mixed $to: a comma delimited list of email addresses in 1 of 2 forms: user@domain.com any number of names <user@domain.com>

Return value

array array of email addresses

1 call to mandrill_get_to()
MandrillTestAPI::sendTemplate in src/MandrillTestAPI.php
Sends a templated Mandrill message.

File

./mandrill.module, line 220
Enables Drupal to send email directly through Mandrill.

Code

function mandrill_get_to($to) {
  $recipients = array();
  $to_array = explode(',', $to);
  foreach ($to_array as $email) {
    if (preg_match(MANDRILL_EMAIL_REGEX, $email, $matches)) {
      $recipients[] = array(
        'email' => $matches[2],
        'name' => $matches[1],
      );
    }
    else {
      $recipients[] = array(
        'email' => $email,
      );
    }
  }
  return $recipients;
}