Hello,
I have a email contact form based on the kirby template.
But some emails are received a second time, 5/6 days later, with the same content, same title. It doesn’t happen systematically, but with an email from time to time.
I use an external SMTP Relay (Mailjet), I contacted them and they didn’t find any problem in the system, and they suggested it was user error (the user click twice and the second email is delayed).
I was wondering if anyone has ever had this problem and if there was any way of anticipating this type of error?
Here’s is my controller
if($kirby->request()->is('POST') && get('submit')) {
if(empty(get('website')) === false) {
go($page->url());
exit;
}
$data = [
'name' => get('name'),
'email' => get('email'),
'number' => get('number'),
'text' => get('text'),
'phone' => get('phone')
];
$rules = [
'name' => ['required', 'minLength' => 3],
'email' => ['required', 'email'],
'number' => ['required', 'minLength' => 1],
'phone' => ['required', 'minLength' => 2],
];
$messages = [
[…]
];
if($invalid = invalid($data, $rules, $messages)) {
$alert = $invalid;
} else {
try {
$kirby->email([
'template' => 'email',
'from' => 'email',
'replyTo' => $data['email'],
'to' => 'email2',
'cc' => 'email3',
'subject' => "contact - " . esc($data['name']),
'data' => [
'text' => esc($data['text']),
'sender' => esc($data['name']),
'email' => esc($data['email']),
'number' => esc($data['number']),
'phone' => esc($data['phone']),
],
]);
]);
} catch (Exception $error) {
[…]
}
if (empty($alert) === true) {
[…]
}
}
}
Thank you for your time and have a nice day.