Пример #1
0
    def setUp(self):
        from repoze.sendmail.delivery import QueuedMailDelivery
        from repoze.sendmail.maildir import Maildir
        self.dir = mkdtemp()
        self.queue_dir = os.path.join(self.dir, "queue")
        self.delivery = QueuedMailDelivery(self.queue_dir)
        self.maildir = Maildir(self.queue_dir, True)
        self.mailer = _makeMailerStub()

        self.save_stderr = sys.stderr
        sys.stderr = self.stderr = StringIO()
Пример #2
0
    def send(self, mto, message):
        """
        keep in mind...
        This is only called inside another thread, after
        transaction has completed
        """
        try:
            from repoze.sendmail import encoding
            encoding.cleanup_message(message)
        except ImportError:
            pass
        messageid = message['Message-Id']
        if messageid is None:
            msgid_domain = self.msgid_domain
            messageid = message['Message-Id'] = make_msgid(domain=msgid_domain)
        if message['Date'] is None:
            message['Date'] = formatdate()

        message['X-Actually-From'] = Header(self.mfrom, 'utf-8')
        message['X-Actually-To'] = Header(','.join(mto), 'utf-8')
        maildir = Maildir(self.queuePath, True)
        tx_message = maildir.add(message)
        tx_message.commit()
        return messageid
Пример #3
0
 def test_add_os_error(self):
     from email.message import Message
     from repoze.sendmail.maildir import Maildir
     self.fake_os_module._exception = OSError('test')
     m = Maildir('/path/to/maildir')
     self.assertRaises(OSError, m.add, Message())
Пример #4
0
 def test_add_no_good_filenames(self):
     from email.message import Message
     from repoze.sendmail.maildir import Maildir
     self.fake_os_module._all_files_exist = True
     m = Maildir('/path/to/maildir')
     self.assertRaises(RuntimeError, m.add, Message())
 def __init__(self, mailer, queue_path, Maildir=Maildir, ignore_transient=False):
     self.mailer = mailer
     self.maildir = Maildir(queue_path, create=True)
     self.ignore_transient = ignore_transient
Пример #6
0
 def setQueuePath(self, path):
     self.maildir = Maildir(path, True)
Пример #7
0
 def test_newMessage_never_loops(self):
     from repoze.sendmail.maildir import Maildir
     from repoze.sendmail.interfaces import IMaildirMessageWriter
     self.fake_os_module._all_files_exist = True
     m = Maildir('/path/to/maildir')
     self.assertRaises(RuntimeError, m.newMessage)
Пример #8
0
 def __init__(self, mailer, queue_path, Maildir=Maildir):
     self.mailer = mailer
     self.maildir = Maildir(queue_path, create=True)