~sambuddhabasu1/mailman/fix_mailman_run_error

4595 by bwarsaw
A functional test, throwing messages at Mailman as fast as you can
1
"""Throw email at Mailman as fast as you can.
2
3
This is not a unit test, it's a functional test, so you can't run it within
4
the unit test framework (hence its filename doesn't start with `test_').
5
Here's how I use this one:
6
7
- set up a dummy list
8
9
- add an alias to your MTA, say `devnull' that pipes its messages to, you
10
  guessed it, /dev/null
11
12
- make this address a member of your list
13
14
- add another address to `accept_these_non_members', let's call it ok@dom.ain
15
16
- change the FROMADDR variable to ok@dom.ain
17
18
- change the LISTADDR variable to point to your list
19
20
- run this program like so: python fblast.py N
21
  where N is the number of seconds to sleep before sending the next msg
22
23
- let this run until you're tired of it, then hit ^C
24
"""
25
26
FROMADDR = 'ok@dom.ain'
27
LISTADDR = 'list@dom.ain'
28
29
import sys
30
import time
31
import smtplib
32
33
conn = smtplib.SMTP()
34
conn.connect()
35
36
snooze = int(sys.argv[1])
37
38
try:
39
    i = 1
40
    while 1:
41
        sys.stdout.write('.')
42
        sys.stdout.flush()
43
        i += 1
44
        if i % 50 == 0:
45
            print
46
        for j in range(10):
47
            conn.sendmail(FROMADDR, [LISTADDR], """\
48
From: %(FROMADDR)s
49
To: $(LISTADDR)s
50
Subject: test %(num)d
51
X-No-Archive: yes
52
53
testing %(num)d
54
""" % {'num'     : i,
55
       'FROMADDR': FROMADDR,
56
       'LISTADDR': LISTADDR,
5800 by twouters
57
       })
4595 by bwarsaw
A functional test, throwing messages at Mailman as fast as you can
58
        time.sleep(snooze)
59
finally:
60
    conn.quit()