You are here

function mandrill_get_to in Mandrill 7

Same name and namespace in other branches
  1. 8 mandrill.module \mandrill_get_to()
  2. 6 mandrill.mail.inc \mandrill_get_to()
  3. 7.2 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()
MandrillMailSystem::mail in lib/mandrill.mail.inc
Send the email message.

File

./mandrill.module, line 362
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;
}