Mail Handler
Send an e-mail through a handler configured in the dashboard.
Quick start
ts
await window.Portal.mailHandler.send('HANDLER_REF', { recipient: 'a@b.com', name: 'Ada' });API reference
window.Portal.mailHandler
Portal.mailHandler — send an e-mail through a handler configured in the dashboard.
get()
Reads a handler (and its provider).
ts
const mailHandlerGetResponse = await window.Portal.mailHandler.get(referenceNum);Parameters
| Name | Type | Required | Description |
|---|---|---|---|
referenceNum | string | Yes | The record's reference number. |
Returns
Resolves with a PortalMailHandlerGetResponse: The answer to Portal.mailHandler.get().
send()
Sends an e-mail with the handler.
ts
const mailHandlerSendResponse = await window.Portal.mailHandler.send(referenceNum, data);Parameters
| Name | Type | Required | Description |
|---|---|---|---|
referenceNum | string | Yes | The record's reference number. |
data | PortalMailHandlerSendPayload | Yes | What Portal.mailHandler.send() sends. |
Returns
Resolves with a PortalMailHandlerSendResponse: The answer to Portal.mailHandler.send().
Types
PortalMailHandler
A mail handler: a named e-mail template/route that can be sent to.
| Name | Type | Required | Description |
|---|---|---|---|
item_reference_num | string | Yes | The handler's item reference. |
name | string | No | The handler's name. |
category | string | No | The handler's category. |
[key: string] | unknown | No | Further fields the server may add. |
PortalMailHandlerGetResponse
The answer to Portal.mailHandler.get().
| Name | Type | Required | Description |
|---|---|---|---|
success | boolean | Yes | True when the call worked. |
provider | PortalMailProvider | Yes | The provider the handlers send through. |
handlers | Record<string, PortalMailHandler> | Yes | The handlers, keyed by their reference. |
PortalMailHandlerSendPayload
What Portal.mailHandler.send() sends. Fields beyond recipient are template variables.
| Name | Type | Required | Description |
|---|---|---|---|
recipient | string | Yes | The address to send to. |
[key: string] | unknown | No | Further fields the server may add. |
PortalMailHandlerSendResponse
The answer to Portal.mailHandler.send().
| Name | Type | Required | Description |
|---|---|---|---|
success | boolean | Yes | True when the e-mail was queued. |
provider | PortalMailProvider | Yes | The provider used. |
handlers | Record<string, PortalMailHandler> | Yes | The handlers, keyed by reference. |
data | PortalMailHandlerSendPayload | Yes | What was sent. |
PortalMailProvider
A configured e-mail provider (the account mail is sent through).
| Name | Type | Required | Description |
|---|---|---|---|
id | number | Yes | Record id. |
reference_num | string | Yes | The provider's reference. |
owner | number | Yes | The member who owns it. |
provider | string | Yes | The provider type, for example 'smtp'. |
name | string | Yes | Internal name. |
label | string | Yes | Display label. |
server | string | Yes | The mail server host. |
status | number | Yes | Active (1) or not (0). |
created_at | string | No | ISO creation time. |
updated_at | string | No | ISO update time. |