🚨 Announcing Vendure v2 Beta

EmailGenerator

EmailGenerator

An EmailGenerator generates the subject and body details of an email.

Signature

interface EmailGenerator<T extends string = any, E extends VendureEvent = any> extends InjectableStrategy {
  onInit?(options: EmailPluginOptions): void | Promise<void>;
  generate(
        from: string,
        subject: string,
        body: string,
        templateVars: { [key: string]: any },
    ): Pick<EmailDetails, 'from' | 'subject' | 'body'>;
}

Extends

Members

onInit

method
type:
(options: EmailPluginOptions) => void | Promise<void>
Any necessary setup can be performed here.

generate

method
type:
(from: string, subject: string, body: string, templateVars: { [key: string]: any }) => Pick<EmailDetails, 'from' | 'subject' | 'body'>
Given a subject and body from an email template, this method generates the final interpolated email text.

HandlebarsMjmlGenerator

Uses Handlebars (https://handlebarsjs.com/) to output MJML (https://mjml.io) which is then compiled down to responsive email HTML.

Signature

class HandlebarsMjmlGenerator implements EmailGenerator {
  onInit(options: EmailPluginOptions | EmailPluginDevModeOptions) => ;
  generate(from: string, subject: string, template: string, templateVars: any) => ;
}

Implements

Members

onInit

method

generate

method
type:
(from: string, subject: string, template: string, templateVars: any) =>