Email Form on Onepager

I’m failing to implement the email form on a one-pager website.

1) How can I alter the controller and snippet to make this work?
Only replacing $page with $part does not seem to do the trick.
I also tried $site (where it made sense), since the form is on the frontpage.

After struggling all evening, I finally made a separate page and template, and the email got sent. At least on my own server, on the server of the client, I’m getting the alert "The form could not be sent".

2) what could be the source of this? An email-form on Kirby 2 with Uniform, on the same server does work.

What exactly isn’t working?

If you’re using this on a one-pager, you should create a controller that matches your template (home.php?), and it should be working as in the cookbook example afaik.

Please replace

 } catch (Exception $error) {
    $alert['error'] = "The form could not be sent";


 } catch (Exception $error) {
    $alert['error'] = $e->getMessage();

So that we hopefully get something more useful on the client’s server.

The also please post the code you are currently using and in which files. Also make sure caching is disabled for the page with the form, in case of your one-page, caching should be disabled.

Thanks a lot @texnixe and @bvdputte,
the combination of renaming the controller to home.php and disable the caching did the trick.
I’ll now look into the problem on the client’s server.

this gives me the Debugger, highlighting this line and reporting

Call to a member function getMessage() on null

Ah, sorry, the variable used is $errorso $error->getMessage()

@texnixe, thanks, now it works:
Error: Could not instantiate mail function.

So I’ll have to look into this

According to the provider, it should work, once the sender is from the same url.
I will know once we switch to the new domain. Fingers crossed!