Receiving Emails
Receive incoming emails through webhooks
A1Base can forward incoming emails to your application via webhooks. When an email is received at your A1Base email address, we’ll send a POST request to your configured webhook URL with the email details. You can configure your webhook on the email dashboard here
⏰ Estimated setup time: 10min.
In this guide you will:
1. Setup a webhook endpoint in your app
- Create a simple endpoint to receive email webhooks
- Use ngrok to expose your local endpoint to the internet
2. Configure webhook URL in A1Mail dashboard
- Go to the email dashboard
- Add your ngrok webhook URL to your A1Mail Dashboard
3. Test receiving emails
- Send a test email from your personal email address to your A1Mail inbox
- View the incoming email data in your webhook endpoint
- Parse and process the email contents as needed
1. Create a Webhook Endpoint
First, create an endpoint in your application to receive email notifications. You can use one of our example snippets below or create your own.
Webhook Implementation Examples
2. Expose Your Local Webhook Endpoint
To receive emails in your inbox, you need to expose your local webhook endpoint to the internet. You can use ngrok to do this. Run the following command in your CLI to start ngrok:
After starting ngrok
-
Find the forwarding URL in the ngrok output:
-
Create the full webhook URL by appending your webhook endpoint path:
-
Use this complete URL in the A1Mail dashboard webhook settings.
3. Register Your Webhook in the Dashboard
Once you have your webhook URL, you need to register it in the A1Mail dashboard:
- Log in to your A1Base Dashboard
- Navigate to the Email Settings section
- Find your email address and click “Configure Webhook”
- Enter your full webhook URL (e.g.,
https://0fcbcda91e79.ngrok.app/webhook/email
) - Click “Save Changes”
Webhook Precedence
When an email is received, A1Mail will attempt to deliver it to a webhook in the following order:
- Individual email address webhook
- Custom domain webhook
- Default webhook
If a webhook is not configured or returns an error, A1Mail will try the next webhook in the precedence list.
4. Test Your Webhook
Send a test email to your inbox and check if the webhook is receiving the email notifications.
Webhook Payload
When an email is received, A1Base will send a POST request to your webhook endpoint with the following JSON payload:
Payload Fields
Field | Type | Description |
---|---|---|
email_id | string | Unique identifier for the received email |
subject | string | Subject line of the email |
sender_address | string | Email address of the sender |
recipient_address | string | Your A1Base email address that received the message |
timestamp | string | ISO 8601 timestamp of when the email was received |
service | string | Always “email” for email webhooks |
raw_email_data | string | Complete raw email content including headers and body |
Example Raw Email Data
The raw_email_data
field contains the complete email including headers, which you can parse to extract additional information like:
- DKIM signatures
- Message ID
- Content type
- Email body (plain text and HTML versions)
- Custom headers
Don’t hesitate to reach out to [email protected] or [email protected] if there’s any features you’d like to see or prioritised!