I'm having issues with Uniform

I’m using the Kirby version 3.9.1.
I’ve installed Uniform into site/plugins/uniform successfully.

However, even when I follow the basic examples and put them into templates, controller, and CSS, it doesn’t seem to work. The error message I’m receiving is: “There was an error sending the form: Could not instantiate mail function.”

Can anyone help me with this?
The URL I’m currently testing is as follows:
http://s962295664.onlinehome.us/test

templates/test.php

      <form action="<?php echo $page->url() ?>" method="POST">
   <input name="email" type="email" value="<?php echo $form->old('email'); ?>">
   <textarea name="message"><?php echo $form->old('message'); ?></textarea>
   <?php echo csrf_field(); ?>
   <?php echo honeypot_field(); ?>
   <input type="submit" value="Submit">
</form>
<?php if ($form->success()): ?>
   Success!
<?php else: ?>
   <?php snippet('uniform/errors', ['form' => $form]); ?>
<?php endif; ?>

controllers/test.php

<?php

use Uniform\Form;

return function ($kirby) {
   $form = new Form([
      'email' => [
         'rules' => ['required', 'email'],
         'message' => 'Email is required',
      ],
      'message' => [],
   ]);

   if ($kirby->request()->is('POST')) {
      $form->emailAction([
         'to' => 'sonahyong@gmail.com',
         'from' => 'sonahyong@gmail.com',
      ])->done();
   }

   return compact('form');
};



I think it sounds like you are trying to use the standard PHP mailer which alot of webhosts disable because its open to spam abuse. Look in the Uniform docs and configure it to use an SMTP connection instead of sending directrly from the sever via PHP.

You are also using the same address for the to and from emails which i think is a red flag for servers. Set the to address to something else like another gmail account or something. Setting the from to noreply@adomainyouown.com might be enough. Obvioulsly replace that with a real domain name.

1 Like

As you mentioned, it was because of the email address.
Thanks you so much :hearts: