Send confirmation email to user after front-end signup

Hi,
I am working on a new project with front-end users, and using the Userskit as a starting point. I have the code shown below, which registers “applicants”, and all is working great. Now I need to send an email to the applicant to notify them their application has been recieved. Fine for this to be plain text for now, just trying to get it working. Where should I be putting the code block from here into my code to get that email sent?

Thanks for any help!
Mike

apply-signin.php (controller)

<?php

return function ($kirby) {

  if($kirby->user()) go('/');

	$error = null;
  $success = null;

	if($kirby->request()->is('POST') and get('application')) {

    try {
      $password = esc(get('password'));
      $validate = esc(get('validate'));

      if(v::same($password, $validate)) {

        $kirby->impersonate('kirby');
        $user = $kirby->users()->create([
          'name'      => esc(get('schoolname')),
          'email'     => esc(get('email')),
          'password'  => esc(get('password')),
          'language'  => 'en',
          'role'      => 'applicant',
          'content'   => [
            'schoolType'           => esc(get('schooltype')),
            'schoolContactName'    => esc(get('schoolcontactname')),
            'schoolContactPhone'   => esc(get('schoolcontactphone')),
          ]
        ]);

        $success = 'The user "' . $user->name() . '" has been created';

      } else {

        $error = 'Please note, passwords must be identical!';

      }

    } catch(Exception $e) {

      $error = $e->getMessage();

    }

	}

	return compact('error', 'success');
};

After $success

That is working perfectly, thanks for the help

@mikeharrison I will try this kit.

Everything works fine in Kirby 3?
Account creation ? Password reset?

I’m looking for something on the front side only, I don’t want my users to connect to the panel.

Hi,
I don’t have password reset set up, but everything else is working fine. I used the Userskit as more of a reference in the end, rather than build on top of it