User registration testing with mailhog

I’m trying to create a registration page for users according to this cookbook recipe: User registration | Kirby CMS

I’ve set up mailhog for testing on my localhost which works when adding this to a page template:

<?php

$kirby->email([
    'template' => 'email',
    'from'     => 'yourcontactform@yourcompany.com',
    'to'       => 'you@yourcompany.com',
    'subject'  => 'Let us test if MailHog works',
    'data'     => [
        'text'   => 'Here is some dummy text',
    ]
]);

However I can’t get it to work with the controller from the recipe. It’s not giving any errors but also not receiving any emails in mailhog. My config looks like this:

return [
    'debug' => true,
    'routes' => [
        [
        'pattern' => 'logout',
        'action'  => function() {
    
            if ($user = kirby()->user()) {
            $user->logout();
            }
    
            go('login');
    
        }
        ]
    ],
    'email' => [
        'transport' => [
          'type' => 'smtp',
          'host' => 'localhost',
          'port' => 1025,
          'security' => false
        ]
      ],
    'auth' => [
        'methods' => ['password', 'code']
    ],
];

How can I get this to work so that I can start testing and using the login?

Alternative question: is there also a recipe where users register with their e-mail and get send a link to set their password?

I’ve spend the last 6 hours to get this to work and tried out lots of different things. Also uploading it to a server and use the settings below but this also doesn’t sent any email.

  'email' => [
    'transport' => [
      'type' => 'smtp',
      'host' => 'MY MAILSERVER',
      'port' => 465,
      'security' => true,
      'auth' => true,
      'username' => 'MY EMAIL',
      'password' => 'MY PASSWORD',
    ]
  ]

I’ve added a /test page with code from my original message and that one is working.

I’ve created a setup with the plainkit. Hopefully someone has the time to look at this and can find the problem/solution: Transfer - Dropbox

I can’t reproduce this on my end. I set your site up in Valet with PHP 8.3, filled out the registration form with test@example.com, and got a code emailed to Mailhog. I also received a code when I filled out the login form. /test works too.

Is the email address you’re using tied to an existing account in the panel?

Hi Luke, Thanks for taking the time to help me out. Could it be a problem with MAMP? I’ve just switched to Herd 1min ago and everything is working the way it should…

Laravel Herd uses hosts, while you might have used a simple localhost address with MAMP?

See User sign-up recipe - "noreply@localhost" is not a valid email address - #4 by texnixe

Yes that might be the case since I used localhost. Now that you mention it I remember running into a similar problem once while testing a contact form. The browser did output an error back then so I knew what the problem was and what to change. Is there a way of logging these errors as well?

Those errors should actually show up in your php error logs?