summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2009-07-24 01:51:22 -0400
committerJason A. Donenfeld <Jason@zx2c4.com>2009-07-24 01:51:22 -0400
commit6443011875d4207a496c5e1c9da56b37e0bcda9a (patch)
treeb91fb951227d7494c28f27ea80c77e10c14f7392
parentUse python's email parser instead of bad self-parsing. (diff)
downloadgeoemail-6443011875d4207a496c5e1c9da56b37e0bcda9a.tar.xz
geoemail-6443011875d4207a496c5e1c9da56b37e0bcda9a.zip
Prepare to look at to lines.
-rw-r--r--src/emailinfo.py4
-rwxr-xr-xsrc/geoemail.py4
2 files changed, 6 insertions, 2 deletions
diff --git a/src/emailinfo.py b/src/emailinfo.py
index deaa285f..5ff17204 100644
--- a/src/emailinfo.py
+++ b/src/emailinfo.py
@@ -7,6 +7,7 @@ import email.utils
import datetime
from weblookuptools import *
from email.parser import Parser
+from email.utils import getaddresses
class EmailInfo:
__location = None
@@ -36,7 +37,7 @@ class EmailInfo:
msg = EmailInfo.parser.parse(file, True)
receiveHosts = []
date = False
- for line in msg.get_all("Received"):
+ for line in msg.get_all("Received", []):
filteredIps = []
#After the "by" or "for" there is no useful information
byIndex = line.find("by")
@@ -64,6 +65,7 @@ class EmailInfo:
date = datetime.datetime.utcfromtimestamp(email.utils.mktime_tz(email.utils.parsedate_tz(msg.get("Date"))))
except:
date = False
+ #recipients = getaddresses(msg.get_all('to', []) + msg.get_all('cc', []) + msg.get_all('bcc', []) + msg.get_all('resent-to', []) + msg.get_all('resent-cc', []) + msg.get_all('resent-bcc', []))
file.close()
#Earlier lines come later in the file, so we look at the file reversed
receiveHosts.reverse()
diff --git a/src/geoemail.py b/src/geoemail.py
index b4ee5d2d..b284c3be 100755
--- a/src/geoemail.py
+++ b/src/geoemail.py
@@ -57,7 +57,9 @@ def processFile(fileName):
try:
examine = EmailInfo.parseFile(fileName)
except:
- parser.error("unable to parse %s" % fileName)
+ if options.debug:
+ print "unable to parse %s" % fileName
+ return
if options.debug and examine.debug:
print fileName + ":",
print examine.debug