Send confirmation email to user after front-end signup

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!

apply-signin.php (controller)


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)) {

        $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