|
@@ -15,7 +15,7 @@ import MemberDescription from '@site/src/components/MemberDescription';
|
|
|
|
|
|
|
|
The EmailEventHandler defines how the EmailPlugin will respond to a given event.
|
|
The EmailEventHandler defines how the EmailPlugin will respond to a given event.
|
|
|
|
|
|
|
|
-A handler is created by creating a new <a href='/reference/typescript-api/core-plugins/email-plugin/email-event-listener#emaileventlistener'>EmailEventListener</a> and calling the `.on()` method
|
|
|
|
|
|
|
+A handler is created by creating a new <a href='/reference/core-plugins/email-plugin/email-event-listener#emaileventlistener'>EmailEventListener</a> and calling the `.on()` method
|
|
|
to specify which event to respond to.
|
|
to specify which event to respond to.
|
|
|
|
|
|
|
|
*Example*
|
|
*Example*
|
|
@@ -143,18 +143,18 @@ class EmailEventHandler<T extends string = string, Event extends EventWithContex
|
|
|
|
|
|
|
|
### constructor
|
|
### constructor
|
|
|
|
|
|
|
|
-<MemberInfo kind="method" type={`(listener: <a href='/reference/typescript-api/core-plugins/email-plugin/email-event-listener#emaileventlistener'>EmailEventListener</a><T>, event: Type<Event>) => EmailEventHandler`} />
|
|
|
|
|
|
|
+<MemberInfo kind="method" type={`(listener: <a href='/reference/core-plugins/email-plugin/email-event-listener#emaileventlistener'>EmailEventListener</a><T>, event: Type<Event>) => EmailEventHandler`} />
|
|
|
|
|
|
|
|
|
|
|
|
|
### filter
|
|
### filter
|
|
|
|
|
|
|
|
-<MemberInfo kind="method" type={`(filterFn: (event: Event) => boolean) => <a href='/reference/typescript-api/core-plugins/email-plugin/email-event-handler#emaileventhandler'>EmailEventHandler</a><T, Event>`} />
|
|
|
|
|
|
|
+<MemberInfo kind="method" type={`(filterFn: (event: Event) => boolean) => <a href='/reference/core-plugins/email-plugin/email-event-handler#emaileventhandler'>EmailEventHandler</a><T, Event>`} />
|
|
|
|
|
|
|
|
Defines a predicate function which is used to determine whether the event will trigger an email.
|
|
Defines a predicate function which is used to determine whether the event will trigger an email.
|
|
|
Multiple filter functions may be defined.
|
|
Multiple filter functions may be defined.
|
|
|
### setRecipient
|
|
### setRecipient
|
|
|
|
|
|
|
|
-<MemberInfo kind="method" type={`(setRecipientFn: (event: Event) => string) => <a href='/reference/typescript-api/core-plugins/email-plugin/email-event-handler#emaileventhandler'>EmailEventHandler</a><T, Event>`} />
|
|
|
|
|
|
|
+<MemberInfo kind="method" type={`(setRecipientFn: (event: Event) => string) => <a href='/reference/core-plugins/email-plugin/email-event-handler#emaileventhandler'>EmailEventHandler</a><T, Event>`} />
|
|
|
|
|
|
|
|
A function which defines how the recipient email address should be extracted from the incoming event.
|
|
A function which defines how the recipient email address should be extracted from the incoming event.
|
|
|
|
|
|
|
@@ -163,35 +163,35 @@ Or with a formatted name (includes unicode support): `'Ноде Майлер <fo
|
|
|
Or a comma-separated list of addresses: `'foobar@example.com, "Ноде Майлер" <bar@example.com>'`
|
|
Or a comma-separated list of addresses: `'foobar@example.com, "Ноде Майлер" <bar@example.com>'`
|
|
|
### setLanguageCode
|
|
### setLanguageCode
|
|
|
|
|
|
|
|
-<MemberInfo kind="method" type={`(setLanguageCodeFn: (event: Event) => <a href='/reference/typescript-api/common/language-code#languagecode'>LanguageCode</a> | undefined) => <a href='/reference/typescript-api/core-plugins/email-plugin/email-event-handler#emaileventhandler'>EmailEventHandler</a><T, Event>`} since="1.8.0" />
|
|
|
|
|
|
|
+<MemberInfo kind="method" type={`(setLanguageCodeFn: (event: Event) => <a href='/reference/typescript-api/common/language-code#languagecode'>LanguageCode</a> | undefined) => <a href='/reference/core-plugins/email-plugin/email-event-handler#emaileventhandler'>EmailEventHandler</a><T, Event>`} since="1.8.0" />
|
|
|
|
|
|
|
|
A function which allows to override the language of the email. If not defined, the language from the context will be used.
|
|
A function which allows to override the language of the email. If not defined, the language from the context will be used.
|
|
|
### setTemplateVars
|
|
### setTemplateVars
|
|
|
|
|
|
|
|
-<MemberInfo kind="method" type={`(templateVarsFn: <a href='/reference/typescript-api/core-plugins/email-plugin/email-plugin-types#settemplatevarsfn'>SetTemplateVarsFn</a><Event>) => <a href='/reference/typescript-api/core-plugins/email-plugin/email-event-handler#emaileventhandler'>EmailEventHandler</a><T, Event>`} />
|
|
|
|
|
|
|
+<MemberInfo kind="method" type={`(templateVarsFn: <a href='/reference/core-plugins/email-plugin/email-plugin-types#settemplatevarsfn'>SetTemplateVarsFn</a><Event>) => <a href='/reference/core-plugins/email-plugin/email-event-handler#emaileventhandler'>EmailEventHandler</a><T, Event>`} />
|
|
|
|
|
|
|
|
A function which returns an object hash of variables which will be made available to the Handlebars template
|
|
A function which returns an object hash of variables which will be made available to the Handlebars template
|
|
|
and subject line for interpolation.
|
|
and subject line for interpolation.
|
|
|
### setSubject
|
|
### setSubject
|
|
|
|
|
|
|
|
-<MemberInfo kind="method" type={`(defaultSubject: string) => <a href='/reference/typescript-api/core-plugins/email-plugin/email-event-handler#emaileventhandler'>EmailEventHandler</a><T, Event>`} />
|
|
|
|
|
|
|
+<MemberInfo kind="method" type={`(defaultSubject: string) => <a href='/reference/core-plugins/email-plugin/email-event-handler#emaileventhandler'>EmailEventHandler</a><T, Event>`} />
|
|
|
|
|
|
|
|
Sets the default subject of the email. The subject string may use Handlebars variables defined by the
|
|
Sets the default subject of the email. The subject string may use Handlebars variables defined by the
|
|
|
setTemplateVars() method.
|
|
setTemplateVars() method.
|
|
|
### setFrom
|
|
### setFrom
|
|
|
|
|
|
|
|
-<MemberInfo kind="method" type={`(from: string) => <a href='/reference/typescript-api/core-plugins/email-plugin/email-event-handler#emaileventhandler'>EmailEventHandler</a><T, Event>`} />
|
|
|
|
|
|
|
+<MemberInfo kind="method" type={`(from: string) => <a href='/reference/core-plugins/email-plugin/email-event-handler#emaileventhandler'>EmailEventHandler</a><T, Event>`} />
|
|
|
|
|
|
|
|
Sets the default from field of the email. The from string may use Handlebars variables defined by the
|
|
Sets the default from field of the email. The from string may use Handlebars variables defined by the
|
|
|
setTemplateVars() method.
|
|
setTemplateVars() method.
|
|
|
### setOptionalAddressFields
|
|
### setOptionalAddressFields
|
|
|
|
|
|
|
|
-<MemberInfo kind="method" type={`(optionalAddressFieldsFn: <a href='/reference/typescript-api/core-plugins/email-plugin/email-plugin-types#setoptionaladdressfieldsfn'>SetOptionalAddressFieldsFn</a><Event>) => `} since="1.1.0" />
|
|
|
|
|
|
|
+<MemberInfo kind="method" type={`(optionalAddressFieldsFn: <a href='/reference/core-plugins/email-plugin/email-plugin-types#setoptionaladdressfieldsfn'>SetOptionalAddressFieldsFn</a><Event>) => `} since="1.1.0" />
|
|
|
|
|
|
|
|
-A function which allows <a href='/reference/typescript-api/core-plugins/email-plugin/email-plugin-types#optionaladdressfields'>OptionalAddressFields</a> to be specified such as "cc" and "bcc".
|
|
|
|
|
|
|
+A function which allows <a href='/reference/core-plugins/email-plugin/email-plugin-types#optionaladdressfields'>OptionalAddressFields</a> to be specified such as "cc" and "bcc".
|
|
|
### setAttachments
|
|
### setAttachments
|
|
|
|
|
|
|
|
-<MemberInfo kind="method" type={`(setAttachmentsFn: <a href='/reference/typescript-api/core-plugins/email-plugin/email-plugin-types#setattachmentsfn'>SetAttachmentsFn</a><Event>) => `} />
|
|
|
|
|
|
|
+<MemberInfo kind="method" type={`(setAttachmentsFn: <a href='/reference/core-plugins/email-plugin/email-plugin-types#setattachmentsfn'>SetAttachmentsFn</a><Event>) => `} />
|
|
|
|
|
|
|
|
Defines one or more files to be attached to the email. An attachment can be specified
|
|
Defines one or more files to be attached to the email. An attachment can be specified
|
|
|
as either a `path` (to a file or URL) or as `content` which can be a string, Buffer or Stream.
|
|
as either a `path` (to a file or URL) or as `content` which can be a string, Buffer or Stream.
|
|
@@ -219,13 +219,13 @@ const testAttachmentHandler = new EmailEventListener('activate-voucher')
|
|
|
```
|
|
```
|
|
|
### addTemplate
|
|
### addTemplate
|
|
|
|
|
|
|
|
-<MemberInfo kind="method" type={`(config: EmailTemplateConfig) => <a href='/reference/typescript-api/core-plugins/email-plugin/email-event-handler#emaileventhandler'>EmailEventHandler</a><T, Event>`} />
|
|
|
|
|
|
|
+<MemberInfo kind="method" type={`(config: EmailTemplateConfig) => <a href='/reference/core-plugins/email-plugin/email-event-handler#emaileventhandler'>EmailEventHandler</a><T, Event>`} />
|
|
|
|
|
|
|
|
Add configuration for another template other than the default `"body.hbs"`. Use this method to define specific
|
|
Add configuration for another template other than the default `"body.hbs"`. Use this method to define specific
|
|
|
templates for channels or languageCodes other than the default.
|
|
templates for channels or languageCodes other than the default.
|
|
|
### loadData
|
|
### loadData
|
|
|
|
|
|
|
|
-<MemberInfo kind="method" type={`(loadDataFn: <a href='/reference/typescript-api/core-plugins/email-plugin/email-plugin-types#loaddatafn'>LoadDataFn</a><Event, R>) => <a href='/reference/typescript-api/core-plugins/email-plugin/email-event-handler-with-async-data#emaileventhandlerwithasyncdata'>EmailEventHandlerWithAsyncData</a><R, T, Event, <a href='/reference/typescript-api/core-plugins/email-plugin/email-plugin-types#eventwithasyncdata'>EventWithAsyncData</a><Event, R>>`} />
|
|
|
|
|
|
|
+<MemberInfo kind="method" type={`(loadDataFn: <a href='/reference/core-plugins/email-plugin/email-plugin-types#loaddatafn'>LoadDataFn</a><Event, R>) => <a href='/reference/core-plugins/email-plugin/email-event-handler-with-async-data#emaileventhandlerwithasyncdata'>EmailEventHandlerWithAsyncData</a><R, T, Event, <a href='/reference/core-plugins/email-plugin/email-plugin-types#eventwithasyncdata'>EventWithAsyncData</a><Event, R>>`} />
|
|
|
|
|
|
|
|
Allows data to be loaded asynchronously which can then be used as template variables.
|
|
Allows data to be loaded asynchronously which can then be used as template variables.
|
|
|
The `loadDataFn` has access to the event, the TypeORM `Connection` object, and an
|
|
The `loadDataFn` has access to the event, the TypeORM `Connection` object, and an
|
|
@@ -250,7 +250,7 @@ new EmailEventListener('order-confirmation')
|
|
|
```
|
|
```
|
|
|
### setMockEvent
|
|
### setMockEvent
|
|
|
|
|
|
|
|
-<MemberInfo kind="method" type={`(event: Omit<Event, 'ctx' | 'data'>) => <a href='/reference/typescript-api/core-plugins/email-plugin/email-event-handler#emaileventhandler'>EmailEventHandler</a><T, Event>`} />
|
|
|
|
|
|
|
+<MemberInfo kind="method" type={`(event: Omit<Event, 'ctx' | 'data'>) => <a href='/reference/core-plugins/email-plugin/email-event-handler#emaileventhandler'>EmailEventHandler</a><T, Event>`} />
|
|
|
|
|
|
|
|
Optionally define a mock Event which is used by the dev mode mailbox app for generating mock emails
|
|
Optionally define a mock Event which is used by the dev mode mailbox app for generating mock emails
|
|
|
from this handler, which is useful when developing the email templates.
|
|
from this handler, which is useful when developing the email templates.
|