Replies: 1 comment 3 replies
-
To send an email with the result of the rendered template you need to assign it to the const html = $template.loadFiles(`${__hooks}/views/welcome.html`).render({ "name": 'Jon Doe', });
const message = new MailerMessage({
from: {
address: $app.settings().meta.senderAddress,
name: $app.settings().meta.senderName,
},
to: [{address: "TO_EMAIL"}],
subject: "YOUR_SUBJECT...",
html: html,
})
$app.newMailClient().send(message) |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi PocketBase Community,
I’m working on a project where I need to send custom HTML emails using event hooks in PocketBase. I’ve referred to the documentation on rendering templates, but the example provided is only for use with routing, not with event hooks.
Specifically, I want to keep my HTML email templates in a separate file and use these templates within my event hooks to send emails. Could someone provide an example or guide me on how to achieve this?
I tried the following code:
const html_email = $template.loadFiles(
${__hooks}/views/welcome.html, ).render({ "name": 'Jon Doe', });
However, I’m not sure if this is the correct approach or if I’m missing something.
Any help or direction on how to properly set up and utilize rendering templates within event hooks for sending custom HTML emails would be greatly appreciated.
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions