I have an inbox with 5000+ emails saying that somebody has signed up. Within the body of the email is their email address and name which I want to store in a database.
Q) How can I get this into a database? Ideally mysql.
Ideally I would like to do this in a PHP which I am most familiar with.
I am using iRedMail with: OpenLDAP
UPDATE: since posting the question I have already written the actual email parser using Plan Cake Email Parser, literally took 5 mins once I found this.
UPDATE 2:
To make things easier I have moved all of the emails I want in the database into a separate IMAP folder.
But when I do a search it returns nothing: find /var/vmail -name ‘Subscribers’ -type d –
UPDATE 3:
Another alternative is that I already have the emails downloaded in my email client locally using Thunderbird Windows 7. When I check my Profiles I can see 3 files related to:
- Subscribers.msf
- Subscribers-1
- Subscribers-1.msf
The real tricky part isn’t parsing the emails, but getting the emails from your server. There are three ways I can think of doing this:
As for parsing, I personally recommend using
grepto find the mails that contain the information you want to extract, andawkto convert this information into a CSV file. You can do text processing using PHP but it’s far simpler and cleaner to do it with these tooks.You can now easily push the data into MySQL.