Falcon_Handler_Mandrill::send_mail PHP Метод

send_mail() публичный Метод

public send_mail ( $users, Falcon_Message $message )
$message Falcon_Message
    public function send_mail($users, Falcon_Message $message)
    {
        $options = $message->get_options();
        $from = Falcon::get_from_address();
        $author = $message->get_author();
        $messages = array();
        foreach ($users as $user) {
            $data = array('from_email' => $from, 'to' => array(array('email' => $user->user_email, 'name' => $user->display_name)), 'subject' => $message->get_subject(), 'headers' => array('Reply-To' => $message->get_reply_address($user)));
            if ($author) {
                $data['from_name'] = $author;
            }
            if ($text = $message->get_text()) {
                $data['text'] = $text;
            }
            if ($html = $message->get_html()) {
                $data['html'] = $html;
            }
            // Set the message ID if we've got one
            if (!empty($options['message-id'])) {
                $data['headers']['Message-ID'] = $options['message-id'];
            }
            // If this is a reply, set the headers as needed
            if (!empty($options['in-reply-to'])) {
                $original = $options['in-reply-to'];
                if (is_array($original)) {
                    $original = isset($options['in-reply-to'][$user->ID]) ? $options['in-reply-to'][$user->ID] : null;
                }
                if (!empty($original)) {
                    $data['headers']['In-Reply-To'] = $original;
                }
            }
            if (!empty($options['references'])) {
                $references = implode(' ', $options['references']);
                $data['headers']['References'] = $references;
            }
            try {
                $messages[$user->ID] = $this->send_single($data);
            } catch (Exception $e) {
                $error = sprintf(__('Exception while sending: %s', 'falcon'), $e->getMessage());
                trigger_error($error, E_USER_WARNING);
            }
        }
        return $messages;
    }