I am a bit stuck. I do have a contact from that is sending me info.
But it is just sending me 3 fields instead of all of them…
I thought it would be the email template that is acting up, but it seems something different. Maybe your set of eyes can find the quick fix…
my html mail:
Hello Company,
<?= $subject ?>
<?= $text ?>
<?= $name ?>
<?= $email ?>
<?= $mobile ?>
<?= $city ?>
<?= $country ?>
<?= $text ?>
Best regards,
<?= $sender ?>
my controller:
<? php
return function($kirby, $site, $pages, $page) {
$alert = null;
if($kirby->request()->is('POST') && get('submit')) {
// check the honeypot
if(empty(get('website')) === false) {
go($page->url());
exit;
}
$data = [
'name' => get('name'),
'email' => get('email'),
'text' => get('text'),
'organization' => get('organization'),
'mobile' => get('mobile'),
'city' => get('city'),
'country' => get('country'),
'subject' => get('subject')
];
$rules = [
'name' => ['required', 'min' => 3],
'email' => ['required', 'email'],
'text' => ['required', 'min' => 3, 'max' => 3000],
];
$messages = [
'name' => 'Please enter a valid name',
'email' => 'Please enter a valid email address',
'text' => 'Please enter a text between 3 and 3000 characters'
];
// some of the data is invalid
if($invalid = invalid($data, $rules, $messages)) {
$alert = $invalid;
// the data is fine, let's send the email
} else {
try {
$kirby->email([
'template' => 'email',
'from' => esc($site->email()),
'replyTo' => $data['email'],
'to' => esc($site->email()),
'subject' => esc($data['name']) . ' sent you a message from your contact form',
'data' => [
'text' => esc($data['text']),
'sender' => esc($data['name']),
'email' => esc($data['email']),
'mobile' => esc($data['mobile']),
'city' => esc($data['city']),
'country' => esc($data['country']),
'subject' => esc($data['subject'])
]
]);
} catch (Exception $error) {
$alert['error'] = "The form could not be sent";
}
// no exception occured, let's send a success message
if (empty($alert) === true) {
$success = 'Your message has been sent, thank you. We will get back to you soon!';
$data = [];
}
}
}
return [
'alert' => $alert,
'data' => $data ?? false,
'success' => $success ?? false
];
};