'Sends one or more EmailMessage objects and returns the number of email messages sent.'

def send_messages(self, messages):

    num_to_send = len(messages)
    first_line = ('Attempting    to    send    %(count)s    emails:    ' % {'count': num_to_send})
    msg_lines = [('%(subject)s    -    %(recipients)r' % {'subject': message.subject, 'recipients': ',    '.join((str(r) for r in message.recipients()))}) for message in messages]
    self.log(logging.DEBUG, (first_line + '\n DCTB '.join(msg_lines)))
    num_sent = (self.real_backend.send_messages(messages) or 0)
    if (num_sent == num_to_send):
        self.log(logging.DEBUG, ('Succesfully    sent    %(sent)s    emails.' % {'sent': num_sent}))
    elif (num_sent < num_to_send):
        self.log(logging.ERROR, ('Failed    to    send    all    emails.    Sent    %(sent)s    out    of    %(to_send)s.' % {'sent': num_sent, 'to_send': num_to_send}))
    else:
        raise AssertionError('Sent    more    emails    than    requested.')
    return num_sent
