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