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
|
||||
try:
|
||||
if not sys.stdin.isatty():
|
||||
email_data = b''
|
||||
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)
|
||||
msg = email.message_from_string(mailcontent)
|
||||
mail_subject = msg.get('Subject').encode("utf-8", "ignore")
|
||||
|
@ -75,22 +79,9 @@ try:
|
|||
email_subject += mail_subject
|
||||
stdin_used = True
|
||||
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:
|
||||
syslog.syslog("FATAL ERROR: Not all required input received")
|
||||
syslog.syslog(str(e))
|
||||
sys.exit(1)
|
||||
|
||||
#if debug:
|
||||
|
|
Loading…
Reference in New Issue