Retrieving emails
Learn how to retrieve messages of your connected accounts.
Feature available for: Google, Microsoft, IMAP.
Get emails history
To get existing emails, use the GET /emails method or the appropriate SDK method.
Most recent messages will be returned first, ordered by date.
By default, the limit of returned messages is set to 100.
You can use lots of parameters to filter by folder, date, recipient, or sender on GET /emails.
curl --request GET \
--url 'https://api.postpress.ai/api/v1/emails?limit=10&account_id=5D586za6a-aAaasqXX' \
--header 'X-API-KEY: {YOUR_ACCESS_TOKEN}' \
--header 'accept: application/json'This method uses pagination.
Get new emails
The postpress API gives you two options to receive emails in your application.
In realtime with Webhooks
The recommended approach to listen for new messages in your application is to use a webhook, because they trigger in real time. Whenever the user account receives or sends a new email, the webhook will call your specified URL with the given email that you can store and display.
→ More information on the new email webhook.
With a cron job
If your system cannot handle webhooks, or if you don't need real time, you can create a cron job that calls GET /emails at intervals.
We advise fetching a larger period than your cron delay to account for any potential disconnects or errors that may result in losing outdated emails. In this case, implementing a unique ID verification on your history entry based on the email ID can help prevent duplicate entries.