# 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
"""SMTP email backend class."""



class EmailBackend(BaseEmailBackend):
    """
    A wrapper that manages the SMTP network connection.
    """
    def __init__(self, host=None, port=None, username=None, password=None,
                 use_tls=None, fail_silently=False, **kwargs):
        super(EmailBackend, self).__init__(fail_silently=fail_silently)
        self.host = host or settings.EMAIL_HOST
        self.port = port or settings.EMAIL_PORT
        if username is None:
            self.username = settings.EMAIL_HOST_USER
        else:
            self.username = username
        if password is None:
            self.password = settings.EMAIL_HOST_PASSWORD
        else:
            self.password = password
        if use_tls is None:

# 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

"""SMTP email backend class."""



class EmailBackend(BaseEmailBackend):
    """
    A wrapper that manages the SMTP network connection.
    """
    def __init__(self, host=None, port=None, username=None, password=None,
                 use_tls=None, fail_silently=False, **kwargs):
        super(EmailBackend, self).__init__(fail_silently=fail_silently)
        self.host = host or settings.EMAIL_HOST
        self.port = port or settings.EMAIL_PORT
        if username is None:
            self.username = settings.EMAIL_HOST_USER
        else:
            self.username = username
        if password is None:
            self.password = settings.EMAIL_HOST_PASSWORD
        else:
            self.password = password
        if use_tls is None:

            self.use_tls = settings.EMAIL_USE_TLS