bernhard: utils/testing mass_mail.py,NONE,1.1
cvs at intevation.de
cvs at intevation.de
Mon Sep 13 11:46:38 CEST 2004
Author: bernhard
Update of /kolabrepository/utils/testing
In directory doto:/tmp/cvs-serv22591
Added Files:
mass_mail.py
Log Message:
Added mass_mail-0.1.py
more description
fake server and email addresses
using Revision for version
--- NEW FILE: mass_mail.py ---
#!/usr/bin/env python
"""Send many random emails to test the KDE Kolab client.
You need to adapt the script to your needs:
- Target server, from and to email address
- Give a filename to a testtext (e.g. from Project Gutenberg.)
This script is Free Software under the GNU General Public License >=v2.
bernhard at intevation.de
"""
#20030723 Bernhard initial (0.1)
__version__="$Revision: 1.1 $"[10:-1]
import sys
import time
import smtplib
import string
import linecache
import random
startnumber=6000
number=12
variants=["a","b","c"]
lv=len(variants)
text_filename="./8ljw111.txt" # Project Gutenberg: Goethe
linewindow_max=42
numbers_of_lines= 2250
def random_passage():
s=""
l=random.randrange(linewindow_max)
start=random.randrange(numbers_of_lines-l)
for i in range(start,start+l):
s=s+linecache.getline(text_filename, i)
return s
fromadd="bernhard16 at moritz.kolab.org"
toadd=["bernhard2.reiter at moritz.kolab.org"]
basemsg=("From: %s\r\nTo: %s\r\n%%s\r\n" % (fromadd, string.join(toadd, ", ")))
headers="MIME-Version: 1.0\r\n"+ \
"Content-Type: text/plain;\r\n"+ \
" charset=\"iso-8859-1\"\r\n"+ \
"Content-Transfer-Encoding: 8bit\r\n"
basesubject="Subject: Stresstest for KDE Kolab Klient 20030723 #%s\r\n"
server=smtplib.SMTP('moritz.kolab.org')
#server.set_debuglevel(1)
for i in range(startnumber,startnumber+number):
subject=basesubject % (str(i+1) + " " + variants[i % lv])
head=basemsg % (headers + subject)
msg=head+random_passage()
server.sendmail(fromadd,toadd,msg)
sys.stdout.write(".")
sys.stdout.flush()
time.sleep(1.0/random.randrange(5,20))
server.quit()
sys.stdout.write("\n")
More information about the commits
mailing list