I created a mail form using Uniform. However, when I try to send the mail, I encounter the following error message: “There was an error sending the form: Could not instantiate mail function.”
It worked on other websites, so I’m not sure why it’s not working here. Even though the hosting is the same, it still doesn’t work. I’ve currently applied reCaptcha, but even after removing it, the same issue persists.
Could someone please look into this? The website is https://wwf.kr, and clicking the “commission” button will bring up the form. You can also test it at https://wwf.kr/recaptcha.
controller
<?php
use Uniform\Form;
return function ($kirby)
{
$form = new Form([
'name' => [
'rules' => ['required'],
'message' => 'Name is required',
],
'email' => [
'rules' => ['required', 'email'],
'message' => 'Email is required',
],
'phone' => [
'rules' => ['required'],
'message' => 'Phone is required',
],
'product_use' => [
'message' => 'Product use is required',
],
'qna' => [
'message' => 'Q&A is required',
],
]);
if ($kirby->request()->is('POST')) {
$form->emailAction([
'to' => 'theman@wwf.kr',
'from' => 'noreply@wwf.kr',
'replyTo' => 'theman@wwf.kr',
'bcc' => get('email'),
'subject' => '[WWF] 새 문의',
'template' => 'email',
]);
}
return compact('form');
};
template
<form class="contact-form" method="POST" autocomplete="off">
<input<?php e($form->hasError('name'), ' class="erroneous"')?> type="text" name="name" id="name" value="<?php $form->echoValue('name') ?>" required placeholder="Name or Company 이름 혹은 회사명">
<input name="email" type="email" value="<?php echo $form->old('email') ?>" required placeholder="E-mail 이메일">
<input type="tel" name="phone" id="phone" value="<?php $form->echoValue('phone') ?>" placeholder="Contact Number 연락처">
<input type="text" name="product_use" id="product_use" value="<?php $form->echoValue('product_use') ?>" placeholder="Artist 작가">
<textarea rows="1" name="qna" id="qna" value="<?php $form->echoValue('qna') ?>" placeholder="Message 문의사항" onclick="resize(this)" onkeydown="resize(this)" onkeyup="resize(this)"></textarea>
<?php echo csrf_field() ?>
<?php echo honeypot_field() ?>
<input class="submit" type="submit" value="Submit">
<?php if ($form->success()): ?>
<div class="contact-info-text">Successfully submitted!</div>
<?php else: ?>
<div class="contact-info-text"><?php snippet('uniform/errors', ['form' => $form]); ?></div>
<?php endif; ?>
</form>