Q:Write a program in Python to analyze email header.
This program simply analyzes a email header stored locally on your machine in a text file and shows information like:
Os: Ubuntu 14.04 LTS
Language: Python
Author: Abhishek Munagekar (Programing Wonders)
Inputs: Just the absolute location of file containing header
This program simply analyzes a email header stored locally on your machine in a text file and shows information like:
- Mime Version
- Date
- Subject
- From
- Delivered To
- To
Os: Ubuntu 14.04 LTS
Language: Python
Author: Abhishek Munagekar (Programing Wonders)
Inputs: Just the absolute location of file containing header
Code
import re def matchre(data,*args): for regstr in args: matchObj = re.search( regstr+'.*', data, re.M|re.I) if matchObj: print matchObj.group(0).lstrip().rstrip() else: print "No ",regstr,"found" print("Email Header Program by Abhishek Munagekar") filename= raw_input("Enter path for email header file\n"); fo = open(filename, "r") #fo=filehandle data=fo.read() matchre(data,"MIME-version","Date:","Subject:","delivered-to:","From:","^to:") fo.close()
No comments:
Post a Comment