title: "EmailPluginOptions" isDefaultIndex: false
import MemberInfo from '@site/src/components/MemberInfo'; import GenerationInfo from '@site/src/components/GenerationInfo'; import MemberDescription from '@site/src/components/MemberDescription';
Configuration for the EmailPlugin.
interface EmailPluginOptions {
templatePath?: string;
templateLoader?: TemplateLoader;
transport:
| EmailTransportOptions
| ((
injector?: Injector,
ctx?: RequestContext,
) => EmailTransportOptions | Promise<EmailTransportOptions>);
handlers: Array<EmailEventHandler<string, any>>;
globalTemplateVars?: { [key: string]: any } | GlobalTemplateVarsFn;
emailSender?: EmailSender;
emailGenerator?: EmailGenerator;
}
Allows you to dynamically load the "globalTemplateVars" key async and access Vendure services to create the object. This is not a requirement. You can also specify a simple static object if your projects doesn't need to access async or dynamic values.
Example
EmailPlugin.init({
globalTemplateVars: async (ctx, injector) => {
const myAsyncService = injector.get(MyAsyncService);
const asyncValue = await myAsyncService.get(ctx);
const channel = ctx.channel;
const { primaryColor } = channel.customFields.theme;
const theme = {
primaryColor,
asyncValue,
};
return theme;
}
[...]
})
type GlobalTemplateVarsFn = (
ctx: RequestContext,
injector: Injector,
) => Promise<{ [key: string]: any }>
Configuration for running the EmailPlugin in development mode.
interface EmailPluginDevModeOptions extends Omit<EmailPluginOptions, 'transport'> {
devMode: true;
outputPath: string;
route: string;
}
Omit<EmailPluginOptions, 'transport'>