Ah now I got it. Thanks for clarifying.
I could not get it running with the email transport, but removing it and just put an ‘email’ works out of the sudden. Anyway, for documentation here is a working code snippet.
site/config/config.php:
<?php
return [
'debug' => true,
'hooks' => [
'page.update:after' => function ($newPage, $oldPage) {
if ($oldPage->intendedTemplate()->name() === 'channel') {
if ($oldPage->artwork()->toBlocks()->count() < $newPage->artwork()->toBlocks()->count() ) {
$lastwork = $newPage->artwork()->toBlocks()->last();
try {
kirby()->email([
'template' => 'new-block',
'from' => 'hallo@url.de',
'to' => 'hallo@url.de',
'subject' => 'New work for you to answer',
'data' => [
'name' => $lastwork->author()->firstname(),
'nextname' => $lastwork->nextartist()->name(),
'link' => $newPage->url(),
'channel' => $newPage->title(),
'date' => $newPage->artwork()->toBlocks()->last()->date(),
'time' => $newPage->artwork()->toBlocks()->last()->time(),
]
]);
} catch (Exception $error) {
echo $error;
}
}
}
}
]
];