User registration - email code not delivered

Hey,

I have been following the cookbook recipe for user registration and although regular emails are working, the ones containing the codes are not being sent.

I am working on a local environment with MAMP and MailHog. When I try to login and request the code, this never arrives to the inbox, but when I send an email following this example, it works.

Here is my config file:

<?php 
return [
  // 'debug' => true,
  // other settings
  'email' => [
    // see https://getkirby.com/docs/guide/emails#transport-configuration
    'transport' => [
      'type' => 'smtp',
      'host' => 'localhost',
      'port' => 1025,
      'security' => false
    ]
  ],
  // see https://getkirby.com/docs/reference/system/options/auth#login-methods
  'auth' => [
      'methods'   => ['code', 'password'],
      'challenge' => [
        'timeout' => 2 * 60, // 5 minutes
        'email' => [
          'from' => 'noreply@yourcompany.com',
          'fromName' => 'New Registrations Dept.',
          'subject'  => 'Login code'
        ]
      ]
  ],
  'routes' => [
    [
      'pattern' => 'logout',
      'action'  => function() {
        if ($user = kirby()->user()) {
          $user->logout();
        }

        go('login');
      }
    ]
  ],
];
?>

Any idea why it might not be working?

try using a from that includes your actual dev domain. the smtp might be picky about that.

'from' => 'noreply@myexample.test',

I am using MAMP Pro on the default host so the address is “localhost:8888/user-registration/”, I tried using “noreply@localhost” but it didn’t work.

To make sure it’s not an issue with the from email, please use a host (e.g. myproject.test) on Mamp Pro. Then add a from address using this host (or leave the from part empty when the host is used).

I created a new host “test.dev” without the ports, move the site there and changed the email address to “noreply@test.dev”. But it is still not working.

Is the smtp port correct? INstead of localhost, try 127.0.0.1

That worked! Thank you!