django_email_multibackend icon indicating copy to clipboard operation
django_email_multibackend copied to clipboard

Backend can return None

Open jsvaughan opened this issue 10 years ago • 3 comments

django_email_multibackend/backends.py", line 126, in send_messages send_count += backend.send_messages(email_messages) TypeError: unsupported operand type(s) for +=: 'int' and 'NoneType'

jsvaughan avatar Jul 17 '14 12:07 jsvaughan

what version of Django are you running?

tbarbugli avatar Jul 17 '14 14:07 tbarbugli

1.4

jsvaughan avatar Jul 17 '14 14:07 jsvaughan

def send_messages(self, email_messages):
    """
    Sends one or more EmailMessage objects and returns the number of email
    messages sent.
    """
    if not email_messages:
        return
    self._lock.acquire()
    try:
        new_conn_created = self.open()
        if not self.connection:
            # We failed silently on open().
            # Trying to send would be pointless.
            return
        num_sent = 0
        for message in email_messages:
            sent = self._send(message)
            if sent:
                num_sent += 1
        if new_conn_created:
            self.close()
    finally:
        self._lock.release()
    return num_sent

jsvaughan avatar Jul 17 '14 14:07 jsvaughan