added starttls support for smtp-source.py

Change-Id: I2a1d3a554f525fac771f7b4ec9f493df56c94a4e
Signed-off-by: SJ <sj@acts.hu>
This commit is contained in:
SJ 2016-08-21 11:58:42 +02:00
parent 64827038de
commit ec98ba33ac

View File

@ -100,9 +100,14 @@ parser.add_argument("-s", "--server", type=str, help="smtp server", required=Tru
parser.add_argument("-p", "--port", type=int, help="smtp port", default=25)
parser.add_argument("--subject", type=str, help="subject", default="This is test subject")
parser.add_argument("-l", "--msglen", type=int, help="message length (approx.)", default=20000)
parser.add_argument("--starttls", help="use STARTTLS", action="store_true")
parser.add_argument("--pem", type=str, help="pem file for starttls", default="")
args = parser.parse_args()
if args.starttls and args.pem == "":
sys.exit("make a pem file for starttls, and add --pem <pem file>")
with open(dictionary) as f:
words = f.readlines()
@ -111,6 +116,9 @@ i = 0
while i < args.count:
server = smtplib.SMTP(args.server, args.port, args.helo, 10)
if args.starttls:
server.starttls(args.pem, args.pem)
k = 0
while i < args.count and k < args.session: