Open stefanfeldner opened 1 year ago
I've just looked into this, and the problem we have is that the EmailGenerator.generate()
interface does not receive the "recipient" value. Changing this interface to also allow it to interpolate the recipient would unfortunately be a breaking change so I'm wondering if there is a workable alternative?
Is there anything that prevents you from, rather than using the handlebars interpolation for the recipient, you just define a constant value and use that?
const RECIPIENT = 'myemail@gmail.com';
// ...
export const customHandler = emailVerificationHandler
.setRecipient(_ => RECIPIENT)
Hey, thank you for checking it out.
The problem here is that we have the handlers in an external handlers.ts
file and would like to use the variables defined in the EmailPlugin vendure-config.ts
but since it's not a Service or something similar we can't inject the PLUGIN_INIT_OPTIONS
to grab it.
But we could just export a regular variable in the vendure-config.ts
, import it in handlers.ts
, and use it as you mentioned above if changing the interface is creating bugs.
Describe the bug I have a custom handler extending the
emailVerificationHandler
and I want to set the recipient to a fixed email from theglobalTemplateVars
. The handler is in a separate file and imported into thevendure-config.ts
. I'm filtering out the existingemailVerificationHandler
and parsing in thecustomHandler
instead.But if I do it like that, I get the following error:
I defined the variable and plugin like this:
It currently looks like it is not possible to set a recipient directly like this because TS expects the event.
To Reproduce Follow the above-mentioned setup or put the
emailVerificationHandler
directly invendure-config.ts
and try to assign the recipient.Expected behavior Should work similarly to the
.setFrom()
function where I can pass a string /globalTemplateVars
variable into the.setRecipient()
Environment: