Uniform form don't send letters

Hi to all,

I’m trying to integrate contacts form

my controller
<?php

use Uniform\Form;

return function ($kirby) {
   $form = new Form([
      'name' => [
         'rules' => ['required'],
         'message' => 'Please enter your name',
      ],
      'email' => [
         'rules' => ['required', 'email'],
         'message' => 'Please provide a valid email',
      ],
      'message' => [
         'rules' => ['required'],
         'message' => 'Please enter a message',
      ],
   ], 'contacts');

   if ($kirby->request()->is('POST')) {
	  $form->honeypotGuard(['field' => 'url']) 
      ->emailAction([
         'to' => 'info@99casinos.com',
         'from' => 'no-reply@99casinos.com',
      ]);
   }

   return compact('form');
};

my template

    <div class="container">
	    <div class="row justify-content-center">
			<div class="col-md-6">
				<form id="contacts" action="<?php echo $page->url() ?>" method="POST">
			      <div class="form-group">
			        <input type="text" class="form-control <?php if ($form->error('name')): ?>is-invalid<?php endif; ?>" placeholder="Your Name" value="<?= $form->old('name'); ?>" id="name" name="name">
			        <?php if ($form->error('name')): ?>
					    <div class="invalid-feedback"><?php echo implode($form->error('name')) ?></div>
					<?php endif; ?>
			      </div>
			      <div class="form-group">
			        <input type="email" class="form-control <?php if ($form->error('email')): ?>is-invalid<?php endif; ?>" placeholder="you@yoursite.com" value="<?= $form->old('email'); ?>" id="email" name="email">
			        <?php if ($form->error('email')): ?>
					    <div class="invalid-feedback"><?php echo implode($form->error('email')) ?></div>
					<?php endif; ?>
			      </div>
			      <div class="form-group">
			        <textarea class="form-control <?php if ($form->error('message')): ?>is-invalid<?php endif; ?>" rows="4" placeholder="Type message here" id="message" name="message"></textarea>
			        <?php if ($form->error('message')): ?>
					    <div class="invalid-feedback"><?php echo implode($form->error('message')) ?></div>
					<?php endif; ?>
			      </div>
			      <div>
				    <?php echo csrf_field(); ?>
					<?php echo honeypot_field(); ?>  
			        <button class="btn btn-primary btn-lg btn-block" type="submit">Send Message</button>
			      </div>
			    </form>
			    <?php if ($form->success()): ?>
				<div  class="alert alert-success" role="alert"><?= t('hooray! your message has been successfully sent.') ?></div>
				<?php endif; ?>
			  </div>
	    </div>
    </div>

testing page
https://new.99casinos.com/contacts

When form have error, I can see it, if everything should be fine. form don’t send success message and the letter is not sending.

Im also try to add to config with and without auth, with and without security.

'email' => ['transport' => [
        'type' => 'smtp',
        'host' => 'mail.99casinos.com',
        'port' => 465,
        'security' => true,
        'auth' => true,
        'username' => 'somemail',
        'password' => 'somepass'
    ]],

don’t have any ideas what it could be…

Locally or on a remote server? Sending mail is usually not possible out of the box in a local dev environment.

It is on working hosting. It was same problem on localhost so, I try to upload it to real hosting for check.

Looks like the honeypot field is missing?

Do you mean in controller? Or where?

In the form. Or am I just blind?

Ok, I’m blind

1 Like

Could it be the reason if I use snippet for insert form to template?

Hm, I think that reason in cloudflare…

if I disable guard ->withoutGuards()
it works

Try using the log function instead of sending mail, maybe that gives us a better idea what’s happening there.

Edit:

Oh, ok. What I find weird is that although you set the honeypot field to URL it is called website. Don’t know if that wrong, I haven’t used Uniform in a while apart from for doing forum debugging.

BTW. Your message field does not keep the value, only the name and email fields do.

I receive the mail with submitted message field. It’s ok.

That’s not my point.

The message field is deleted if there’s an error in one of the other fields, so that’s not really user friendly.

1 Like

ahhh… thanks. will check it. :slight_smile:

The corresponding code for the message field is missing.

Should be something like this:

<textarea class="form-control <?php if ($form->error('message')): ?>is-invalid<?php endif; ?>" rows="4" placeholder="<?php if ($form->old('message')): ?><?= $form->old('message'); ?><?php else: ?>Type message here<?php endif; ?>" id="message" name="message"></textarea>

Also problem was really in this