Email Plugin Types

Email Plugin Types

EventWithContext

A VendureEvent which also includes a ctx property containing the current RequestContext, which is used to determine the channel and language to use when generating the email.

Signature

type EventWithContext = VendureEvent & { ctx: RequestContext }

EventWithAsyncData

A VendureEvent with a RequestContext and a data property which contains the value resolved from the EmailEventHandler.loadData() callback.

Signature

type EventWithAsyncData<Event extends EventWithContext, R> = Event & { data: R }

SMTPCredentials

The credentials used for sending email via SMTP

Signature

interface SMTPCredentials {
  user: string;
  pass: string;
}

Members

user

property
type:
string
The username

pass

property
type:
string
The password

EmailDetails

The final, generated email details to be sent.

Signature

interface EmailDetails<Type extends 'serialized' | 'unserialized' = 'unserialized'> {
  from: string;
  recipient: string;
  subject: string;
  body: string;
  attachments: Array<Type extends 'serialized' ? SerializedAttachment : Attachment>;
}

Members

from

property
type:
string

recipient

property
type:
string

subject

property
type:
string

body

property
type:
string

attachments

property
type:
Array<Type extends 'serialized' ? SerializedAttachment : Attachment>

LoadDataFn

A function used to load async data for use by an EmailEventHandler.

Signature

type LoadDataFn<Event extends EventWithContext, R> = (context: {
    event: Event;
    injector: Injector;
}) => Promise<R>

EmailAttachment

An object defining a file attachment for an email. Based on the object described here in the Nodemailer docs, but only uses the path property to define a filesystem path or a URL pointing to the attachment file.

Signature

type EmailAttachment = Omit<Attachment, 'content' | 'raw'> & { path: string }

EmailTemplateConfig

Configures the EmailEventHandler to handle a particular channel & languageCode combination.

Signature

interface EmailTemplateConfig {
  channelCode: string | 'default';
  languageCode: LanguageCode | 'default';
  templateFile: string;
  subject: string;
}

Members

channelCode

property
type:
string | 'default'
Specifies the channel to which this configuration will apply. If set to 'default', it will be applied to all channels.

languageCode

property
type:
LanguageCode | 'default'
Specifies the languageCode to which this configuration will apply. If set to 'default', it will be applied to all languages.

templateFile

property
type:
string
Defines the file name of the Handlebars template file to be used to when generating this email.

subject

property
type:
string
A string defining the email subject line. Handlebars variables defined in the templateVars object may be used inside the subject.

SetTemplateVarsFn

A function used to define template variables available to email templates. See EmailEventHandler.setTemplateVars().

Signature

type SetTemplateVarsFn<Event> = (
    event: Event,
    globals: { [key: string]: any },
) => { [key: string]: any }

SetAttachmentsFn

A function used to define attachments to be sent with the email. See https://nodemailer.com/message/attachments/ for more information about how attachments work in Nodemailer.

Signature

type SetAttachmentsFn<Event> = (event: Event) => EmailAttachment[] | Promise<EmailAttachment[]>