bh: utils/testing send_filtertest_emails.py,1.8,1.9
cvs at intevation.de
cvs at intevation.de
Mon Jun 27 15:27:06 CEST 2005
Author: bh
Update of /kolabrepository/utils/testing
In directory doto:/tmp/cvs-serv24242/testing
Modified Files:
send_filtertest_emails.py
Log Message:
add a new parameter to the send_mail function so that the caller can set
the body text of the mail. The callers now call send_mail with the new
parameter set to a text that describes the expected result of the mail
(delivery/bounce)
Also, catch exceptions and print tracebacks when sending an email fails
so that the rest of the mails will still get sent.
Index: send_filtertest_emails.py
===================================================================
RCS file: /kolabrepository/utils/testing/send_filtertest_emails.py,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- send_filtertest_emails.py 17 Jun 2005 09:33:20 -0000 1.8
+++ send_filtertest_emails.py 27 Jun 2005 13:27:04 -0000 1.9
@@ -22,9 +22,11 @@
import smtplib
import string
import getopt
+import traceback
def send_mail(envelope_from, envelope_to, header_from, header_to,
- test_number=-1, smtp_host="localhost", smtp_port = None):
+ test_number=-1, smtp_host="localhost", smtp_port = None,
+ text = "this is a kolab testmail"):
basemsg=("From: %s\r\nTo: %s\r\n%%s\r\n" %
(header_from, string.join(header_to, ", "))
@@ -38,17 +40,21 @@
subject="Subject: envelope header from test %d\r\n" % int(test_number)
head=basemsg % (headers + subject)
- msg=head+"Hello!\n"
- server=smtplib.SMTP(smtp_host, smtp_port)
- #server.set_debuglevel(1)
+ msg = head + text + "\n"
- server.sendmail(envelope_from,envelope_to,msg)
- #sys.stdout.write(".")
- #sys.stdout.flush()
+ try:
+ server=smtplib.SMTP(smtp_host, smtp_port)
+ #server.set_debuglevel(1)
- server.quit()
- #sys.stdout.write("\n")
+ server.sendmail(envelope_from,envelope_to,msg)
+ #sys.stdout.write(".")
+ #sys.stdout.flush()
+
+ server.quit()
+ except:
+ print "Error sending mail %d" % (test_number,)
+ traceback.print_exc()
def assemble_email_address(username, domain, realname = None):
@@ -134,28 +140,33 @@
# 0: delivered: Are we functional? Do the standard settings work?
send_mail(envelope_from, envelope_to, header_from, header_to, 0,
- smtp_host = smtp_host, smtp_port = smtp_port)
+ smtp_host = smtp_host, smtp_port = smtp_port,
+ text = "Kolab filter testmail.\nExpected result: delivery")
# 1: delivered: different letter cases in the header_from
send_mail(envelope_from, envelope_to, header_from.swapcase(), header_to, 1,
- smtp_host = smtp_host, smtp_port = smtp_port)
+ smtp_host = smtp_host, smtp_port = smtp_port,
+ text = "Kolab filter testmail.\nExpected result: delivery")
# 2: bounce mail: different from and host envelope
send_mail(envelope_from, envelope_to, "rumpelstilzchen at big.invalid",
header_to, 2,
- smtp_host = smtp_host, smtp_port = smtp_port)
+ smtp_host = smtp_host, smtp_port = smtp_port,
+ text = "Kolab filter testmail.\nExpected result: bounce")
# 3: delivered, no mailer-daemon in kolabfilter log:
# issue774 (null senders not handled by kolabfilter...)
send_mail("<>", envelope_to, "some at non-existing.invalid", header_to, 3,
- smtp_host = smtp_host, smtp_port = smtp_port)
+ smtp_host = smtp_host, smtp_port = smtp_port,
+ text = "Kolab filter testmail.\nExpected result: delivery")
# 4: delivered, no Invalid From: header in postfix log:
# issue783 (envelope header from check has problems with mailinglists)
send_mail("x-commits-bounces-+y=malinglist.org at example.org", envelope_to,
header_from, header_to, 4,
- smtp_host = smtp_host, smtp_port = smtp_port)
+ smtp_host = smtp_host, smtp_port = smtp_port,
+ text = "Kolab filter testmail.\nExpected result: delivery")
if __name__=="__main__":
main(sys.argv)
More information about the commits
mailing list