Skip to main content

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'>;}

onInit

method(options: EmailPluginOptions) => void | Promise<void>

Any necessary setup can be performed here.

generate

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

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: InitializedEmailPluginOptions) => ;    generate(from: string, subject: string, template: string, templateVars: any) => ;}

onInit

method(options: InitializedEmailPluginOptions) =>

generate

method(from: string, subject: string, template: string, templateVars: any) =>
Was this chapter helpful?
Report Issue
Edited Feb 2, 2026·Edit this page