I’m in the process of finalising my latest Kirby site (having not used it for a while). I’m using Uniform to create a contact form and it all works fine. It even displays the correct messages when submitting the form to send the mail, both errors and success.
The issue I have is that even though it says “Success!”, no mail ever arrives - yes, I have checked in the Spam folder!
Here is my form:
<form action="<?php echo $page->url() ?>#contact-notice" method="POST" id="contactform">
<fieldset>
<legend>Get in touch with Us</legend>
<div class="form-row">
<label for="name">Name <span class="req">*</span></label>
<input<?php if ($contactform->error('name')): ?> class="error"<?php endif; ?> name="name" id="name" type="text" placeholder="Your name" value="<?php echo $contactform->old('name') ?>">
</div>
<div class="form-row">
<label for="email">E-mail <span class="req">*</span></label>
<input<?php if ($contactform->error('email')): ?> class="error"<?php endif; ?> name="email" id="email" type="email" placeholder="Your e-mail" value="<?php echo $contactform->old('email') ?>">
<?php echo honeypot_field('url','contact-website-hp') ?>
</div>
<div class="form-row">
<label for="phone">Phone</label>
<input name="phone" id="phone" type="text" placeholder="Your phone" value="<?php if ($contactform->old('phone')): echo $contactform->old('phone'); endif; ?>">
</div>
<div class="form-row">
<label for="message" class="message-label">Message <span class="req">*</span></label>
<textarea<?php if ($contactform->error('message')): ?> class="error"<?php endif; ?> name="message" id="message" placeholder="Your message..."><?php echo $contactform->old('message') ?></textarea>
</div>
<div class="form-row asf">
<?php echo csrf_field() ?>
<input type="hidden" name="submittedfrom" value="<?= $page->url() ?>">
<label for="as-result">Anti-spam question: What is <?php echo uniform_captcha() ?>? <span class="req">*</span></label>
<?php echo captcha_field('as-result', 'field-asf'); ?>
</div>
<a id="contact-notice"></a>
<div class="form-row button-row">
<input type="hidden" name="formid" value="contact">
<input type="submit" class="button primary" value="Send Message">
</div>
</fieldset>
</form>
<?php if ($contactform->success()): ?>
<div class="uniform-success">
Thank you for your message. We will get in touch soon!
</div>
<?php else: ?>
<?php snippet('uniform/errors', ['form' => $contactform]) ?>
<?php endif; ?>
And here is my controller:
return function ($kirby)
{
$contactform = new Form([
'name' => [
'rules' => ['required'],
'message' => 'Please enter your name',
],
'email' => [
'rules' => ['required', 'email'],
'message' => 'Please enter a valid email address',
],
'phone' => [],
'message' => [
'rules' => ['required'],
'message' => 'Please enter a message',
],
'submittedfrom' => [],
'as-result' => [
'rules' => ['required', 'num'],
'message' => 'Please fill in the calculation field',
],
],'contact-form');
if ($kirby->request()->is('POST')) {
$contactform
->honeypotGuard(['field' => 'url'])
->calcGuard(['field' => 'as-result'])
->emailAction([
'to' => 'name@address.co.uk',
'from' => 'website@address.co.uk',
'subject' => 'Contact form submission from {{name}} via address.co.uk'
])->done();
}
return compact('contactform');
};
I’m using Kirby 5.0.3 and Uniform 5.7.0, running on PHP 8.4
I feel like I’m going around in circles on this and could really do with some guidance on how to error check it all. There is nothing in the error log for the host.