Webhook Forwarding
Emails sent to Private Email Addresses (or Catch-All addresses) can be forwarded to a URL also known as a webhook.
Configure Webhook

Select Manage Email Addresses from the Dashboard. Choose Settings next to the email address. In the Forward to Custom Webhook setting enter the webhook address and select Save Settings
Configure webhook forwarding on an enhanced address using curl
curl -H "Mailsac-Key: YOUR_API_KEY_HERE" \
-H "Content-Type: application/json" \
-X PUT https://mailsac.com/api/private-address-forwarding/bclinton@mailsac.com \
--data '{"webhook": "https://mywebsite.com/webhooks"}'
# Curl Output
{
"_id": "bclinton@mailsac.com",
"owner": "mailsac_user",
"forward": null,
"enablews": false,
"webhook": "https://mywebsite.com/webhooks",
"webhookSlack": null,
"webhookSlackToFrom": null,
"catchAll": null,
"password": null,
"info": "",
"created": "2020-08-19T23:31:15.664Z",
"updated": "2020-08-25T13:59:05.430Z"
}
Configure webhook forwarding on an enhanced address using
Node.js. requires
npm install superagent
const superagent = require('superagent')
superagent
.put('https://mailsac.com/api/private-address-forwarding/bclinton@mailsac.com')
.set('Mailsac-Key', 'YOUR_API_KEY_HERE')
.send({
webhook: "https://mywebsite.com/webhooks"
})
.then((res) => {
console.log(res.body)
})
.catch(err => {
console.log(err.message)
})
/*
{ _id: 'bclinton@mailsac.com',
owner: 'mailsac_user',
forward: null,
enablews: false,
webhook: 'https://mywebsite.com/webhooks',
webhookSlack: null,
webhookSlackToFrom: null,
catchAll: null,
password: null,
info: '',
created: '2020-08-19T23:31:15.664Z',
updated: '2020-08-25T14:04:34.261Z' }
*/
Configure webhook forwarding on an enhanced address using
Python.
import requests
from pprint import pprint
headers = {'Mailsac-Key': 'YOUR_API_KEY_HERE'}
url = 'https://mailsac.com/api/private-address-forwarding/bclinton@mailsac.com'
data = { 'webhook':'https://mywebsite.com/webhooks' }
r = requests.put(url, data=data, headers=headers)
pprint(r.json())
'''
{'_id': 'bclinton@mailsac.com',
'catchAll': None,
'created': '2020-08-19T23:31:15.664Z',
'enablews': False,
'forward': None,
'info': '',
'owner': 'mailsac_user',
'password': None,
'updated': '2020-08-25T14:11:14.695Z',
'webhook': 'https://mywebsite.com/webhooks',
'webhookSlack': None,
'webhookSlackToFrom': None}
'''
Webhook Sample JSON
This is an example of the JSON that will be passed to the Webhook URL.
{"text": "this is a message",
"headers": {
"dkim-signature": "redacted",
"received": "2017-05-01T05:22:03.000Z",
"content-type": "text/plain",
"from": "mastadon@mailsac.com",
"to": "gemini@mailsac.com",
"subject": "",
"message-id": "",
"list-unsubscribe": "",
"content-transfer-encoding": "7bit",
"date": "Wed, 1 May 2017 05:22:03 +0000",
"mime-version": "1.0"
},
"subject": "twin",
"messageId": "MS-5412430010104145004240335343@mailsac.com",
"priority": "normal",
"from": [{
"address": "mastadon@mailsac.com",
"name": ""
}],
"to": [{
"address": "gemini@mailsac.com",
"name": ""
}],
"date": "2017-05-01T05:22:03.000Z",
"receivedDate": "2017-05-01T05:22:03.000Z",
"originalInbox": "gemini@mailsac.com",
"inbox": "gemini@mailsac.com",
"domain": "mailsac.com",
"encryptedInbox": "inbox-db54b7f5f09041165aaaaae5ca9557c806cf3d95f8",
"raw": "DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailsac.com;\r\n q=dns/txt; s=mailsacrelay;\r\n bh=redacted;\r\n h=from:subject:to:mime-version:content-type:content-transfer-encoding:list-unsubscribe;\r\n b=redacted\r\nReceived: from localhost (127.0.0.1) by mailer with SMTP; Wed May 1\r\n 2017 01:22:03 GMT-0400 (EDT)\r\nContent-Type: text/plain\r\nFrom: mastadon@mailsac.com\r\nTo: gemini@mailsac.com\r\nSubject: twin\r\nMessage-ID:\r\n \r\nList-Unsubscribe: \r\nContent-Transfer-Encoding: 7bit\r\nDate: Wed, 1 May 2017 05:22:03 +0000\r\nMIME-Version: 1.0\r\n\r\this is a message",
"received": "2017-05-01T05:22:04.851Z",
"_id": "IhnBcuaaiC",
"ip": "127.0.0.1"
}
Webhook contents are very similar to web socket emails.
Read more about JSON Webhooks at the API Reference
Troubleshooting
If the Webhook forwarding is not working, additional debugging information is available in Recent Activity.