Creating reusable emails

I am looking at this

I follow the manual to create something like this:

namespace App\Mailer;

use Cake\Mailer\Mailer;

class ArticleMailer extends Mailer
    public function implementedEvents()
        return [
            'Model.afterSave' => 'onPost'
    public function onPost(Event $event, EntityInterface $entity, ArrayObject $options)
        if ($entity->isNew()) {
            $this->send('newarticle', [$entity]);
    public function newarticle($article)
            ->setSubject(sprintf('New article posted %s', $article->name))

According to the manual this should work fine, but when adding a new article it does not get triggered? Am I missing some extra step I need to do that is not mentioned in the manual?

So I need to register the Mailer class on the model?

$articleMailer = new ArticleMailer();

Now when I add an article it gets triggered but it is showing errors:

Argument 1 passed to App\Mailer\ArticleMailer::onPost() must be an instance of App\Mailer\Event, instance of Cake\Event\Event given