Just upgraded to kirby 3.5 and am not sure why this is happening but once the form is submitted the browser sits and waits until it finally times out and the try catch block fails.
config:
<?php
return [
'email' => [
'transport' => [
'type' => 'smtp',
'host' => 'stmp.hostname.com',
'port' => 465,
'security' => 'ssl',
'auth' => true,
'username' => '...',
'password' => '...'
]
],
'debug' => true,
'languages' => true
];
controller:
<?php
return function ($kirby, $pages, $page, $site) {
$seoTitle = $page->ogTitle() . " | " . $site->title();
$seoDescription = $page->ogDescription();
$ogImage = null;
$ogImageAlt = null;
if ($site->ogImage()->toFile()) :
$ogImage = $site->ogImage()->toFile()->resize(1200, 630)->url();
$ogImageAlt = $site->ogImage()->toFile()->alt();
endif;
$ogURL = $page->url();
$ogSite = $site->title();
$alert = null;
if ($kirby->request()->is('POST') && get('contact_submit')) {
$data = [
'name' => get('contact_name')
];
$rules = [
'name' => ['required', 'min' => 2]
];
$messages = [
'name' => 'Please enter a valid name, minimum 2 characters'
];
if ($invalid = invalid($data, $rules, $messages)) {
$alert = $invalid;
} else {
try {
$kirby->email([
'template' => 'contact',
'from' => 'websites@websites.com',
'to' => 'email@email.com',
'subject' => 'New Website Contact Form Submission',
'data' => [
'name' => esc($data['name'])
]
]);
} catch (Exception $error) {
$alert['error'] = "Failed to send form (Error kode 1)";
}
if (empty($alert) === true) {
$success = 'Thank you, your message has been sent. We will get back to you soon!';
$data = [];
}
}
}
$data = $data ?? false;
$success = $success ?? false;
return compact('seoTitle', 'seoDescription', 'ogImage', 'ogImageAlt', 'ogURL', 'ogSite', 'alert', 'data', 'success');
};
Form finally times out after about a minute and will show the error message within the catch block.
Works locally off XAMPP/Windows 10
Fails on linux server.
I’ve checked for capitals in my file names, intelliphense isn’t detecting any problems…i’m out of ideas as this code is just boilerplate i’ve used many times before.