Videos
Check out our tutorial video series.
Receive emails with http webhooks. Webhooks let you respond to inbound email streams in real time on your server or within an application.
Email webhooks enable the forwarding of incoming emails to custom server endpoints. Webhooks are configured so that mailservers can forward received emails directly to subscribing servers. This allows your system to respond to emails and attachments as they arrive without long-polling or continual checking of email inboxes.
MailSlurp provides many ways to receive an email. One popular method is using webhooks. Webhooks enable you to receive emails and attachments directly to your server when they arrive without the need to call MailSlurp directly. Webhooks must be created using the dashboard or API and assigned to an inbox. You can attach a single webhook to multiple inboxes if you wish to receive emails and attachments across many addresses.
See the Webhoook developer documentation for model schemas, event types and examples.
Every MailSlurp inbox can be connected to a webhook. Webhooks are rules that forward a payload to an HTTP endpoint that is publicly accessible on your server or system. MailSlurp will post a JSON payload to your server when a webhook event is triggered.
Webhooks can be setup to trigger for different events:
(or
) - triggered when an inbox receives a new email
- triggered when a new recipient or sender is encountered on an incoming email
- triggered when a new attachment is received in an emailEach Webhook has an associated triggering event. The event type determines what type of JSON payload will be sent to your server.
- sent when a
webhook is triggered.
- sent when a
webhook is triggered.
- sent when a
webhook is triggered.When webhooks are triggered a JSON payload will be sent via HTTP POST to your server URL. Your server must return a 200 or 201 response status within 30 seconds. If so the webhook is marked as successfully processed. If not the webhook will be placed in a queue and retried until a success is obtained.
First create an inbox. Then you can create a webhook online in the webapp or using the API or SDKs. You must define a URL for the webhook that can be called by MailSlurp servers using HTTP POST method.
Use the WebhookControllerAPI endpoints or the methods available in the SDKs to create and manage webhooks.
You can also create a webhook using the dashboard:
You can share a webhook across multiple inboxes by attaching the same webhook ID to each new inbox you create.
In the MailSlurp dashboard you can monitor your webhook history to see how your webhooks are being handled.
We recommend you use a service like ngrok.io to test webhooks. It allows you to tunnel a localhost to a publicly accessible url so that MailSlurp can call your local test machine.
Webhooks are guaranteed to be sent at least once. Efforts are made to deliver only once but they may occasionally be sent multiple times due to the distribute queue system used. To mitigate duplication use the event to differentiate between events. Store the
and acknowledge but do not process the event if you encounter the same ID again.
Expose an endpoint on your server and create a MailSlurp webhook using the URL. Listen for incoming events and return a 200.
Let's see how a webhook fits together with an example Javascript server using Express.
Note: you can use any framework or language you like with webhooks.
The WebhookPayload class is included in the MailSlurp SDKs and can be used to deserialize the webhook payload. For instance:
See the developer webhook documentation for payload schemas.
Check out our tutorial video series.
Email and SMS guides for automation and testing.
View github project code for multiple languages.
Latest posts from the MailSlurp team.
Test, build, and automate messaging with a free MailSlurp account.