update
This commit is contained in:
17
extract_email_headers.py
Normal file
17
extract_email_headers.py
Normal file
@@ -0,0 +1,17 @@
|
||||
import sys
|
||||
import email
|
||||
|
||||
if len(sys.argv) < 2:
|
||||
print("Usage: python3 extract_email_headers.py <email_file>")
|
||||
sys.exit(1)
|
||||
|
||||
file_path = sys.argv[1]
|
||||
with open(file_path, 'rb') as f:
|
||||
msg = email.message_from_bytes(f.read())
|
||||
|
||||
from_addr = msg.get('From', '')
|
||||
to_addrs = msg.get_all('To', []) + msg.get_all('Cc', [])
|
||||
recipients = ','.join([str(addr) for addr in to_addrs]) if to_addrs else ''
|
||||
|
||||
print(f'FROM:{from_addr}')
|
||||
print(f'RECIPIENTS:{recipients}')
|
||||
Reference in New Issue
Block a user