Moving parsed email data to my database (MySQL, Postgres, MongoDB, ...)?
A common use-case is to store the parsed email data in a database such as MySQL, Postgres or MongoDB. There are two ways how you can easily have your parsed data transferred to your local database:
- Use Zapier as the middleman between mailparser.io and your database
- Develop a simple script in your preferred language which resides on your server
The first method involves creating an account with Zapier. The advantage of this method is that no programming is necessary and that you should have something running in a couple of minutes. If you want to give it a try, have a look here for MySQL, here for Postgres and here for MongoDB.
The second method involves developing a script in your preferred programming language which resides on your server and has access to your database. This script will receive the parsed data from a mailparser.io webhook (a standard HTTP Post request) and create a new record in your local database for each received webhook.
The advantage of the second method is that you don't need another account with Zapier because your data is sent directly from mailparser.io to your server. If you have the possibility and resources, developing a simple custom script is our recommended way.
This is how you would set up a webhook which sends your parsed data to your database using a custom script:
- Check that all parsing rules work correctly and that your data gets extracted as expected
- Develop a script which is able to read data from a HTTP request (POST or GET parameters) and can store the received data in your database
- Create a new "Generic Webhook" in the section "Webhook Integrations" of your inbox
- Set the target of the webhook to the location of your script (e.g. yourdomain.com/my_script.php)
- Choose in which format your data should be sent (Form data, JSON, XML) and which HTTP method we should use for the request (POST, PUT, GET), ...
- Send a test webhook and check if your data was stored correctly in your database
- From now on, a new webhook request is sent to your script for each newly parsed email
If you have difficulties with the development of your script or if you want to debug your setup, the following two tools can probably help you:
- requestb.in: A service which lets you create a temporary endpoint (URL) to which you can point your webhook. This is a simple method if you want to check how the webhook requests to your script would look like.
- Postman: A chrome plugin which allows you to make HTTP requests to any script (locally or remote). You can for example imitate the payload of our webhooks while developing on your local machine.