bernhard: utils/testing test-send-emails-headerencodings.py, NONE, 1.1
cvs at kolab.org
cvs at kolab.org
Tue Apr 22 21:57:33 CEST 2008
Author: bernhard
Update of /kolabrepository/utils/testing
In directory doto:/tmp/cvs-serv6449
Added Files:
test-send-emails-headerencodings.py
Log Message:
Adding a testscript for sending email with interesting
encodings in the headers.
--- NEW FILE: test-send-emails-headerencodings.py ---
#!/usr/bin/env python
"""Send Email with special From: headers that can tickle out problems.
Usage $progname <recipientemailaddress>
This script is Free Software under the GNU General Public License >=v2.
bernhard at intevation.de (initial 20080422)
"""
__version__="$Revision: 1.1 $"
# $Source: /kolabrepository/utils/testing/test-send-emails-headerencodings.py,v $
import sys
import smtplib
import string
msgbase="""Subject: %s
From: %s
Date: Thu, 15 Mar 2008 15:17:02 +0200
MIME-Version: 1.0
No frills.
"""
msg1 = msgbase % ("Test1, Email with base64 enc From and Comma",
"=?iso-8859-1?B?5Hf8b2xmLPZBbmRyZWFz?= <nobody at example.org>")
msg2 = msgbase % ("Test2, email with quoted printable From incl Comma",
"=?us-ascii?Q?Surname=2C=20Name?= <nobody at example.org>")
toadd = [sys.argv[1]]
smtpserver='localhost'
# if you set a loginname, aconnection via TLS and authentification is tried
loginname = None
password = None
fromadd="nobody at example.org"
basemsg=("From: %s\r\nTo: %s\r\n%%s\r\n" % (fromadd, string.join(toadd, ", ")))
server=smtplib.SMTP(smtpserver)
#server.set_debuglevel(1)
if loginname != None and password != None:
server.starttls()
server.login(loginname,password)
server.sendmail(fromadd,toadd,msg1)
server.sendmail(fromadd,toadd,msg2)
server.quit()
More information about the commits
mailing list