I have a plugin that sends an email when a user submits a form.
When trying to send that email with an email template that is registered in the same plugin, I get an error message that “The email template “contact” cannot be found”.
Sending the email works when I define the email content via “body” or when I put the email template in /site/templates/emails/contact.html.php
The function that processes the form input and sends the email is placed after the plugin method:
<?php
Kirby::plugin('datenliebe/myplugin', [
'templates' => [
'emails/contact.html' => __DIR__ . '/templates/emails/contact.html.php'
]
]);
if (kirby()->request()->is('POST')) {
try {
kirby()->email([
'template' => 'contact',
...
]);
}
}
I have already checked this issue and the following topic but cannot figure out how to fix my implementation.
Do you see what I am missing?