Passwordless login email sending problem

I installed mailhog and configured kirby

This is my config options

return [
    'debug' => true,
    
    'auth' => [
    'methods' => ['code']
    ],
    
    'email' => [
    'transport' => [
      'type' => 'smtp',
      'host' => 'localhost',
      'port' => 1025,
      'security' => false
    ]
  ],
  

];

Using panel passwordless login I don’t receive any code by email.

Using this code in a template I receive test email!

<?php 

try {
  $kirby->email([
    'from' => 'welcome@supercompany.com',
    'replyTo' => 'no-reply@supercompany.com',
    'to' => 'someone@gmail.com',
    'cc' => 'anotherone@gmail.com',
    'bcc' => 'secret@gmail.com',
    'subject' => 'Welcome!',
    'body'=> 'It\'s great to have you with us',
  ]);
} catch (Exception $error) {
  echo $error;
}

?>

Sounds like a kirby problem.

Suggestions?

Thanks in advance

Should work, though.

Which Kirby version are you using in which sort of environment?

In my local installation with Kirby 3.8.3, Laravel Valet and MailHog running in a Docker container, it works without issues.

Local installation on MacOS Ventura, MAMP (Apache), PHP 8.0.8, with Kirby 3.8.3 and MailHog running on localhost.

The email is not sent even using google’s smtp server.
Is there a way to view send logs?

What you could try on the command line:

log stream --predicate  '(process == "smtpd") || (process == "smtp")' --info

Not sure if that works with MailHog, though.

Hi @texnixe
with your suggested command line no log is displayed.
I copied everything on a hosting server and I used settings of a real smtp server as transport configuration:
the problem is the same:

  • mail sending via passwordless request panel fails: no email received
  • mail sending using $kirby->email() in a template works perfectly: mail received

Does the user with the email address you are using exist?

Yes sure!
I have created and tested several accounts.
With auth method “password” no problem, with auth method “code” emails are not being sent.
Same problem occurs not only using panel login but also using the code to allow user signin via frontend (https://getkirby.com/docs/cookbook/forms/user-registration#frontend-login-with-code)

Have you tested this with a fresh Starterkit?

I’ve just done it! (fresh starterkit; fresh plainkit) same problem (locally and on public hosting)

I also updated php to version 8.1

Have you checked your php error logs?

In case you are getting "noreply@localhost" is not a valid email address set the auth.challenge.email.from option in your config to a valid email address.

Perfect! That was the problem!
Thank you!

The reason why I don’t run into such problems locally is because I always use hosts, but that’s a MAMP Pro feature.