This commit is contained in:
2025-12-10 15:21:26 -06:00
parent a5fe94df66
commit cfdd840527
2 changed files with 135 additions and 92 deletions

17
extract_email_headers.py Normal file
View 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}')