aboutsummaryrefslogtreecommitdiffstats
path: root/tests/fblast.py
blob: 2add94588a4e3ad117a3c307a40b656cf98ef577 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
"""Throw email at Mailman as fast as you can.

This is not a unit test, it's a functional test, so you can't run it within
the unit test framework (hence its filename doesn't start with `test_').
Here's how I use this one:

- set up a dummy list

- add an alias to your MTA, say `devnull' that pipes its messages to, you
  guessed it, /dev/null

- make this address a member of your list

- add another address to `accept_these_non_members', let's call it ok@dom.ain

- change the FROMADDR variable to ok@dom.ain

- change the LISTADDR variable to point to your list

- run this program like so: python fblast.py N
  where N is the number of seconds to sleep before sending the next msg

- let this run until you're tired of it, then hit ^C
"""

FROMADDR = 'ok@dom.ain'
LISTADDR = 'list@dom.ain'

import sys
import time
import smtplib

conn = smtplib.SMTP()
conn.connect()

snooze = int(sys.argv[1])

try:
    i = 1
    while 1:
        sys.stdout.write('.')
        sys.stdout.flush()
        i += 1
        if i % 50 == 0:
            print
        for j in range(10):
            conn.sendmail(FROMADDR, [LISTADDR], """\
From: %(FROMADDR)s
To: $(LISTADDR)s
Subject: test %(num)d
X-No-Archive: yes

testing %(num)d
""" % {'num'     : i,
       'FROMADDR': FROMADDR,
       'LISTADDR': LISTADDR,
       }
        time.sleep(snooze)
finally:
    conn.quit()