function mandrill_map_mail_recipients in Mandrill 7.2
Parses & creates Mandrill-style array with recipients.
Parameters
$emails string: Comma-separated string with emails.
string $type string: Type of email. Mandrill supports "to", "cc" and "bcc".
Return value
array Array of recipients.
See also
https://mandrillapp.com/api/docs/messages.html
2 calls to mandrill_map_mail_recipients()
- MandrillMailSystem::mail in lib/
mandrill.mail.inc - Send the email message.
- mandrill_get_to in ./
mandrill.module - Helper to generate an array of recipients.
File
- ./
mandrill.module, line 667 - Enables Drupal to send email directly through Mandrill.
Code
function mandrill_map_mail_recipients($emails, $type = 'to') {
$recipients = array();
$email_array = explode(',', $emails);
foreach ($email_array as $email) {
if (preg_match(MANDRILL_EMAIL_REGEX, $email, $matches)) {
$recipients[] = array(
'email' => $matches[2],
'name' => $matches[1],
'type' => $type,
);
}
else {
$recipients[] = array(
'email' => $email,
'type' => $type,
);
}
}
return $recipients;
}