Beispiel #1
0
def pytest_configure(config):
    monkey_patch_SMTPChannel()

    global smtp_test_server
    smtp_test_server = SMTPTestServer(('localhost', 2525), None)
    smtp_test_server.start()

    config = pkg_resources.resource_filename('spamalot.tests', 'test.ini')
    spamalot.init_mailer(config)
Beispiel #2
0
        for recipient in self.recipients:
            if recipient["email"] in to_addrs:
                msg = self._prepare_message(recipient)
                self._single_send(recipient, msg)
                time.sleep(delay)
            else:
                self.log.debug("skipping %s" % recipient["email"])

    def send(self):
        self.log.info("spamming started, found %d recipients" % len(self.left_addrs))

        attempt = 1
        tot_attemps = 3
        while attempt <= tot_attemps and self.left_addrs:
            self.log.debug("start attempt #%d" % attempt)
            self._send(self.left_addrs)
            attempt -= 1

        if not self.left_addrs:
            self.log.info("spamming finished, everything fine capt'n!")
        else:
            self.log.warning("there are %d left email to send!" % len(self.left_addrs))


if __name__ == "__main__":
    spamalot.init_mailer("spam.ini")
    mailer = spamalot.Mailer(batch=True)
    spammer = Spammer(mailer)
    spammer.send()