# Path: airy/core/conf.py
# class Settings(object):
#     def __init__(self, **entries):
#     def __getattribute__(self, name):
# def _ensure_defaults(dsettings, options, project_root, config_filename):
# def _preconfigure(project_root, config_filename='settings.py', argv=[]):
# 
# Path: airy/core/mail/message.py
# def sanitize_address(addr, encoding):
#     if isinstance(addr, basestring):
#         addr = parseaddr(force_unicode(addr))
#     nm, addr = addr
#     nm = str(Header(nm, encoding))
#     try:
#         addr = addr.encode('ascii')
#     except UnicodeEncodeError:  # IDN
#         if u'@' in addr:
#             localpart, domain = addr.split(u'@', 1)
#             localpart = str(Header(localpart, encoding))
#             domain = domain.encode('idna')
#             addr = '@'.join([localpart, domain])
#         else:
#             addr = str(Header(addr, encoding))
#     return formataddr((nm, addr))


import smtplib
import socket
import threading
from airy.core.conf import settings
from airy.core.mail.backends.base import BaseEmailBackend
from airy.core.mail.utils import DNS_NAME
from airy.core.mail.message import sanitize_address
    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

    def _send(self, email_message):
        """A helper method that does the actual sending."""
        if not email_message.recipients():
            return False
        from_email = sanitize_address(email_message.from_email, email_message.encoding)

# Path: airy/core/conf.py
# class Settings(object):
#     def __init__(self, **entries):
#     def __getattribute__(self, name):
# def _ensure_defaults(dsettings, options, project_root, config_filename):
# def _preconfigure(project_root, config_filename='settings.py', argv=[]):
# 
# Path: airy/core/mail/message.py
# def sanitize_address(addr, encoding):
#     if isinstance(addr, basestring):
#         addr = parseaddr(force_unicode(addr))
#     nm, addr = addr
#     nm = str(Header(nm, encoding))
#     try:
#         addr = addr.encode('ascii')
#     except UnicodeEncodeError:  # IDN
#         if u'@' in addr:
#             localpart, domain = addr.split(u'@', 1)
#             localpart = str(Header(localpart, encoding))
#             domain = domain.encode('idna')
#             addr = '@'.join([localpart, domain])
#         else:
#             addr = str(Header(addr, encoding))
#     return formataddr((nm, addr))


# Path: airy/core/mail/backends/smtp.py
import smtplib
import socket
import threading
from airy.core.conf import settings
from airy.core.mail.backends.base import BaseEmailBackend
from airy.core.mail.utils import DNS_NAME
from airy.core.mail.message import sanitize_address

    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

    def _send(self, email_message):
        """A helper method that does the actual sending."""
        if not email_message.recipients():
            return False
        from_email = sanitize_address(email_message.from_email, email_message.encoding)

        recipients = [sanitize_address(addr, email_message.encoding)