From 98d0145af3edb7de4c81353491e9963a41eace1b Mon Sep 17 00:00:00 2001 From: CIRCL Date: Fri, 2 Jun 2017 11:13:28 +0200 Subject: [PATCH] fixed larger size mails handling --- fake_smtp.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fake_smtp.py b/fake_smtp.py index 8039fb1..c325e1d 100755 --- a/fake_smtp.py +++ b/fake_smtp.py @@ -1,6 +1,7 @@ #!/usr/bin/python3 import os import sys +import tempfile try: configfile = os.path.basename(sys.argv[0]).split(".py")[0] + "_config" except Exception as e: @@ -28,7 +29,11 @@ class CustomSMTPServer(smtpd.SMTPServer): print('Message addressed from: {0}'.format(mailfrom)) print('Message addressed to : {0}'.format(rcpttos)) print('Message length : {0}'.format(len(data))) - subprocess.call([binpath, data]) + tf = tempfile.NamedTemporaryFile(mode='w', delete=False) + tf.write(data) + tf.close() + subprocess.call([binpath, "-r", tf.name]) + os.unlink(tf.name) return server = CustomSMTPServer((smtp_addr, smtp_port), None)