I would like a php script, i imagine it will need sql for storage, that logs in to my gmail goes through all my emails and extracts the to from and cc and the email addresses within the text of the email, from forwarded and multiply forwarded emails, and tags them as where the came from ie to from cc and inline.
whats the best way to go about it i have no idea where to start
Here's a pseudocode using PHP - each step should be simple enough to implement on its own.
- connect to database using the
mysqli
extension - log into gmail using the
imap
extension and its functions- get a list of folders
- for each folder
- get a list of messages, and their headers
- for each message (you may want to check and reject obvious spam here)
- get message headers and body
- look for the From: To: CC: and BCC: headers
- store those into database (those are your tags)
- use a regular expression to match possible e-mail addresses
- if matches found:
- store them into database, linked with the tags
- disconnect from gmail
- disconnect from database
This should be a good place to start:
http://code.google.com/apis/gmail/
精彩评论