/utils/resend
The resend module provides a way to send emails to clients/admins, etc.
The resend dependency will be imported dynamically on the condition that a TRANSPORT_EMAIL [sender] is defined the process environment.
The mailer object has two methods. send and batch. The send function sends one email. And the batch function queues a batch of emails to be sent.
- Source
Requires
Methods
(async, inner) batch(emails)
Takes an array of emails to queue via the resend sdk. This allows us to trigger 100 emails at once.
| Name | Type | Description |
|---|---|---|
emails | Array |
| Name | Type | Description |
|---|---|---|
params.to | String | The email recipient. |
params.template | String | The html that will make up the body of the email. |
params.language | String | The language to be used. |
params.host | String | The URL of the instance. |
- Source
(async, inner) getBody(template) → {Promise.<(Error|undefined)>}
Retrieves the body of the text from the provided url/file. The html is removed from a template with text.
Text and html values without a provider prefix are inline bodies and are kept as is. An error is returned if a src reference fails to load.
| Name | Type | Description |
|---|---|---|
template | Object |
| Name | Type | Description |
|---|---|---|
template.text | String | The inline text or the src reference from which to retrieve the text content using module:/provider/getSrc. |
template.html | String | The inline html or the src reference from which to retrieve the html content using module:/provider/getSrc. |
- Source
An error if a src reference failed to load.
- Type:
- Promise.<(Error|undefined)>
(async, inner) getMailTemplate(params) → {Promise.<(Object|Error)>}
Creates the mail template for the resend sdk from the language template and body for the params.
| Name | Type | Description |
|---|---|---|
params | Object |
| Name | Type | Description |
|---|---|---|
params.to | String | The email recipient. |
params.template | String | The language template for the email. |
- Source
The mail template or an error if the template body failed to load.
- Type:
- Promise.<(Object|Error)>
(inner) replaceStringParams(string) → {String}
Substitutes supplied params into a supplied string.
| Name | Type | Description |
|---|---|---|
string | String |
| Name | Type | Description |
|---|---|---|
params | Object | The parameters to substitute into the string. |
- Source
The string with substitutions made.
- Type:
- String
(async, inner) send(params)
Sends one email via the resend sdk.
| Name | Type | Description |
|---|---|---|
params | Object |
| Name | Type | Description |
|---|---|---|
params.to | String | The email recipient. |
params.template | String | The html that will make up the body of the email. |
params.language | String | The language to be used. |
params.host | String | The URL of the instance. |
- Source