Exemplo n.º 1
0
 def __init__(self, md):
     self.md = md
     settings = get_config_settings()
     white_list_fn = settings.get("mail_white_list", None)
     if white_list_fn:
         with open(white_list_fn) as f:
             self.white_list = set(
                 self._normalize(line) for line in f.readlines())
     else:
         self.white_list = None
Exemplo n.º 2
0
 def send(self, mto, msg):
     assert isinstance(msg, Message), \
            'Message must be instance of email.message.Message'
     try:
         from repoze.sendmail import encoding
         encoding.cleanup_message(msg)
     except ImportError:
         pass
     messageid = msg['Message-Id']
     if messageid is None:
         settings = get_config_settings()
         msgid_domain = settings.get('msgid_domain', None)
         messageid = msg['Message-Id'] = make_msgid(domain=msgid_domain)
     if msg['Date'] is None:
         msg['Date'] = formatdate()
     transaction.get().join(self.createDataManager(self.mfrom, mto, msg))
     return messageid
Exemplo n.º 3
0
def mail_delivery_factory(os=os):  # accepts 'os' for unit test purposes
    """Factory method for creating an instance of repoze.sendmail.IDelivery
    for use by this application.
    """
    settings = get_config_settings()

    # If settings utility not present, we are probably testing and should
    # suppress sending mail.  Can also be set explicitly in environment
    # variable
    suppress_mail = boolean(os.environ.get('SUPPRESS_MAIL', ''))

    if not settings or suppress_mail:
        return FakeMailDelivery()

    md = KarlMailDelivery(settings)
    if settings.get("mail_white_list", None):
        md = WhiteListMailDelivery(md)
    return md
Exemplo n.º 4
0
 def config_settings(self):
     return get_config_settings()
Exemplo n.º 5
0
 def __init__(self, settings=None):
     if settings is None:
         settings = get_config_settings()
         self.msgid_domain = settings.get('msgid_domain', None)
     super(ThreadedGeneratorMailDelivery, self).__init__(settings)
Exemplo n.º 6
0
Arquivo: api.py Projeto: lslaz1/karl
 def config_settings(self):
     return get_config_settings()