/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.

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.

Parameters:
NameTypeDescription
emailsArray
Properties
NameTypeDescription
params.toString

The email recipient.

params.templateString

The html that will make up the body of the email.

params.languageString

The language to be used.

params.hostString

The URL of the instance.

(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.

Parameters:
NameTypeDescription
templateObject
Properties
NameTypeDescription
template.textString

The inline text or the src reference from which to retrieve the text content using module:/provider/getSrc.

template.htmlString

The inline html or the src reference from which to retrieve the html content using module:/provider/getSrc.

Returns:

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.

Parameters:
NameTypeDescription
paramsObject
Properties
NameTypeDescription
params.toString

The email recipient.

params.templateString

The language template for the email.

Returns:

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.

Parameters:
NameTypeDescription
stringString
Properties
NameTypeDescription
paramsObject

The parameters to substitute into the string.

Returns:

The string with substitutions made.

Type: 
String

(async, inner) send(params)

Sends one email via the resend sdk.

Parameters:
NameTypeDescription
paramsObject
Properties
NameTypeDescription
params.toString

The email recipient.

params.templateString

The html that will make up the body of the email.

params.languageString

The language to be used.

params.hostString

The URL of the instance.