# Contact form is not working, how to debug this?

**URL:** <https://community.modx.com/t/contact-form-is-not-working-how-to-debug-this/6909>\
**Category:** Random\
**Created:** [July 25, 2023, 7:18pm UTC](https://community.modx.com/t/contact-form-is-not-working-how-to-debug-this/6909 "2023-07-25T19:18:31Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![mark537](https://community.modx.com/user_avatar/community.modx.com/mark537/32/3194_2.png) [@mark537](https://community.modx.com/u/mark537)\
**Post date:** [July 25, 2023, 7:18pm UTC](https://community.modx.com/t/contact-form-is-not-working-how-to-debug-this/6909/1 "2023-07-25T19:18:31Z")

</div>

At first, I tried to make this using AjaxForm but that was not working, after that, I tried without AjaxForm but it’s not working. Just reloading the page.  
How can I figure out the issue?

```auto
[[!FormIt?
    &hooks=`email,redirect`
    &form=`contact_form`
    &redirectTo=`7`
    &emailSubject=`New Case from`
    &emailTo=`cybertech537@gmail.com`
    &validationErrorMessage=`The form contains errors!`
    &successMessage=`Message sent successfully`
    &validate=`nospam:blank,
        email:email:required`
]] 

```

```auto
[[!+fi.validation_error_message:notempty=`<p>[[!+fi.validation_error_message]]</p>`]]		
<form action="[[~[[*id]]]]" method="post" class="">
    <input type="hidden" name="nospam" value="" />
    
    <div class="consult-form">
        <div class="">
            <input type="text" name="fullname" placeholder="Name*" value="[[!+fi.fullname]]" required>
            <p class="error">[[!fi.error.fullname]]</p>
        </div>
        <div class="">
            <input type="text" name="phone" placeholder="Phone*" value="[[!+fi.phone]]" required>
            <p class="error">[[!fi.error.phone]]</p>
        </div>
        <div class="">
            <input type="email" name="email" placeholder="E-mail*" value="[[!+fi.email]]" required>
            <p class="error">[[!fi.error.email]]</p>
        </div>
        <div class="">
            <input type="text" name="subject" placeholder="Subject" value="[[!+fi.subject]]">
            <p class="error">[[!fi.error.subject]]</p>
        </div>
        <div class="col-span-2">
            <textarea name="message" placeholder="Briefly describe your legal situation*" required>[[!+fi.message]]</textarea>
            <p class="error">[[!fi.error.message]]</p>
        </div>
    </div>
		
    <button name="send" type="submit" class="FormButton FormSubmit"><span>SUBMIT</span></button>
    
    [[+fi.success:is=`1`:then=`
        <div class="alert alert-success">[[+fi.successMessage]]</div>
    `]]
    [[+fi.validation_error:is=`1`:then=`
        <div class="alert alert-danger">[[+fi.validation_error_message]]</div>
    `]]
</form>

```

---

<div class="post-metadata">

**Author:** ![halftrainedharry](https://community.modx.com/user_avatar/community.modx.com/halftrainedharry/32/1063_2.png) [@halftrainedharry](https://community.modx.com/u/halftrainedharry)\
**Post date:** [July 25, 2023, 7:44pm UTC](https://community.modx.com/t/contact-form-is-not-working-how-to-debug-this/6909/2 "2023-07-25T19:44:21Z")

</div>

> [@mark537](#):
>
> `[[!fi.error.fullname]]`

The only thing I can see that is wrong, is that some of the placeholder are missing the `+` → `[[!fi.error.fullname]]` instead of `[[!+fi.error.fullname]]`. (But this shouldn’t prevent the form from working.)

- Are there any errors in the MODX error log?
- Does it redirect if you remove the `email` hook?

---

<div class="post-metadata">

**Author:** ![mark537](https://community.modx.com/user_avatar/community.modx.com/mark537/32/3194_2.png) [@mark537](https://community.modx.com/u/mark537)\
**Post date:** [July 25, 2023, 8:36pm UTC](https://community.modx.com/t/contact-form-is-not-working-how-to-debug-this/6909/3 "2023-07-25T20:36:03Z")

</div>

I downloaded the log file and it has lots of errors.  
How can I solve these?

 ![image](https://modx-community.s3.dualstack.us-east-1.amazonaws.com/original/2X/0/05eb23d2a18b836e322a61b15c47a8fea82e2217.png)  
 ![image](https://modx-community.s3.dualstack.us-east-1.amazonaws.com/original/2X/c/cddea48464351ef597353b42b941fbe6f3aea1bf.png)

---

<div class="post-metadata">

**Author:** ![mark537](https://community.modx.com/user_avatar/community.modx.com/mark537/32/3194_2.png) [@mark537](https://community.modx.com/u/mark537)\
**Post date:** [July 25, 2023, 8:42pm UTC](https://community.modx.com/t/contact-form-is-not-working-how-to-debug-this/6909/4 "2023-07-25T20:42:45Z")

</div>

> [@halftrainedharry](#):
>
> Does it redirect if you remove the `email` hook?

Yes, It redirects but the mail doesn’t go.

---

<div class="post-metadata">

**Author:** ![halftrainedharry](https://community.modx.com/user_avatar/community.modx.com/halftrainedharry/32/1063_2.png) [@halftrainedharry](https://community.modx.com/u/halftrainedharry)\
**Post date:** [July 25, 2023, 8:47pm UTC](https://community.modx.com/t/contact-form-is-not-working-how-to-debug-this/6909/5 "2023-07-25T20:47:14Z")

</div>

> [@mark537](#):
>
> How can I solve these?

The error in the printscreen you posted can be fixed by changing the “Resource Alias” of either the resource with ID = 80 or ID = 216, as these seem to have the same value.

* * *

> [@mark537](#):
>
> Yes, It redirects but the mail doesn’t go.

Try to explicitly set the `emailFrom` property.

```auto
[[!FormIt?
   ...
   &emailFrom=`from@yourdomain.com`
]]

```

If you have a field with `name="email"`, _FormIt_ uses the value of this field as the _from address_, which usually creates a problem.

---

<div class="post-metadata">

**Author:** ![mark537](https://community.modx.com/user_avatar/community.modx.com/mark537/32/3194_2.png) [@mark537](https://community.modx.com/u/mark537)\
**Post date:** [July 25, 2023, 8:54pm UTC](https://community.modx.com/t/contact-form-is-not-working-how-to-debug-this/6909/6 "2023-07-25T20:54:20Z")

</div>

> [@halftrainedharry](#):
>
> Try to explicitly set the `emailFrom` property.

Still it’s not working.

```auto
[[!FormIt?
  &emailTpl=`MyEmailChunk`
  &hooks=`redirect`
  &redirectTo=`7`
  &emailFrom=`info@internetlava.com`
  &emailTo=`cybertech537@gmail.com`
  &validate=`nospam:blank,
      email:email:required`
]]

```

---

<div class="post-metadata">

**Author:** ![halftrainedharry](https://community.modx.com/user_avatar/community.modx.com/halftrainedharry/32/1063_2.png) [@halftrainedharry](https://community.modx.com/u/halftrainedharry)\
**Post date:** [July 25, 2023, 8:55pm UTC](https://community.modx.com/t/contact-form-is-not-working-how-to-debug-this/6909/7 "2023-07-25T20:55:50Z")

</div>

> [@mark537](#):
>
> `&hooks=`redirect` `

Maybe put the `email` hook back in.

---

<div class="post-metadata">

**Author:** ![mark537](https://community.modx.com/user_avatar/community.modx.com/mark537/32/3194_2.png) [@mark537](https://community.modx.com/u/mark537)\
**Post date:** [July 25, 2023, 9:05pm UTC](https://community.modx.com/t/contact-form-is-not-working-how-to-debug-this/6909/8 "2023-07-25T21:05:21Z")

</div>

Yes, It works now. Made my day.

---

<div class="post-metadata">

**Author:** ![mark537](https://community.modx.com/user_avatar/community.modx.com/mark537/32/3194_2.png) [@mark537](https://community.modx.com/u/mark537)\
**Post date:** [July 26, 2023, 4:52pm UTC](https://community.modx.com/t/contact-form-is-not-working-how-to-debug-this/6909/9 "2023-07-26T16:52:49Z")

</div>

@halftrainedharry

Hi, I need your assistance.

- I need to send the user email to multiple addresses. I did it like `&emailTo=`cybertech537@gmail.com,mdjahidulislam712@gmail.com` and it’s working. I don’t know whether it’s the correct way or not

- Besides, the user/visitor will receive a confirmation email that the administrator got his mail and will contact him soon.  
For example:

---

<div class="post-metadata">

**Author:** ![halftrainedharry](https://community.modx.com/user_avatar/community.modx.com/halftrainedharry/32/1063_2.png) [@halftrainedharry](https://community.modx.com/u/halftrainedharry)\
**Post date:** [July 26, 2023, 7:10pm UTC](https://community.modx.com/t/contact-form-is-not-working-how-to-debug-this/6909/10 "2023-07-26T19:10:12Z")

</div>

> [@mark537](#):
>
> I don’t know whether it’s the correct way or not

Yes, that’s the correct way. There exist also other properties that you could use like `emailBCC` or `emailCC`.  
Take a look a the documentation:

[https://docs.modx.com/current/en/extras/formit/formit.hooks/email](https://docs.modx.com/current/en/extras/formit/formit.hooks/email)

* * *

> [@mark537](#):
>
> the user/visitor will receive a confirmation email

There is the “FormItAutoResponder” hook for that:

[https://docs.modx.com/current/en/extras/formit/formit.hooks/formitautoresponder](https://docs.modx.com/current/en/extras/formit/formit.hooks/formitautoresponder)

---

<div class="post-metadata">

**Author:** ![mark537](https://community.modx.com/user_avatar/community.modx.com/mark537/32/3194_2.png) [@mark537](https://community.modx.com/u/mark537)\
**Post date:** [July 27, 2023, 12:16am UTC](https://community.modx.com/t/contact-form-is-not-working-how-to-debug-this/6909/11 "2023-07-27T00:16:38Z")

</div>

Thanks a ton, brother. 💚
