mirror of https://github.com/MISP/mail_to_misp
refactored some code parts
parent
8d124413b9
commit
fd091a4a01
|
@ -56,8 +56,12 @@ stdin_used = False
|
||||||
email_subject = config.email_subject_prefix
|
email_subject = config.email_subject_prefix
|
||||||
try:
|
try:
|
||||||
if not sys.stdin.isatty():
|
if not sys.stdin.isatty():
|
||||||
email_data = b''
|
|
||||||
mailcontent = sys.stdin.buffer.read().decode("utf-8", "ignore")
|
mailcontent = sys.stdin.buffer.read().decode("utf-8", "ignore")
|
||||||
|
else:
|
||||||
|
mailcontent = sys.argv[1]
|
||||||
|
if len(sys.argv) >= 3:
|
||||||
|
email_subject = sys.argv[2]
|
||||||
|
email_data = b''
|
||||||
syslog.syslog(mailcontent)
|
syslog.syslog(mailcontent)
|
||||||
msg = email.message_from_string(mailcontent)
|
msg = email.message_from_string(mailcontent)
|
||||||
mail_subject = msg.get('Subject').encode("utf-8", "ignore")
|
mail_subject = msg.get('Subject').encode("utf-8", "ignore")
|
||||||
|
@ -75,22 +79,9 @@ try:
|
||||||
email_subject += mail_subject
|
email_subject += mail_subject
|
||||||
stdin_used = True
|
stdin_used = True
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
syslog.syslog("EXCEPTION")
|
|
||||||
syslog.syslog(str(e))
|
|
||||||
pass
|
|
||||||
|
|
||||||
try:
|
|
||||||
if not stdin_used:
|
|
||||||
email_data = sys.argv[1]
|
|
||||||
if len(sys.argv) < 3:
|
|
||||||
#email_subject = "(No Subject)"
|
|
||||||
msg = email.message_from_string(email_data)
|
|
||||||
email_subject = msg.get('Subject').encode("utf-8", "ignore")
|
|
||||||
else:
|
|
||||||
email_subject = sys.argv[2]
|
|
||||||
except:
|
|
||||||
if debug:
|
if debug:
|
||||||
syslog.syslog("FATAL ERROR: Not all required input received")
|
syslog.syslog("FATAL ERROR: Not all required input received")
|
||||||
|
syslog.syslog(str(e))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
#if debug:
|
#if debug:
|
||||||
|
|
Loading…
Reference in New Issue