No Clue about Formit

Hello

I can’t get, how formit works to send out email from forms.
I gut, That I first have to create ha HTML form page…and then? Sadly, the MODX docs are not helping here at all.
They write

Simply place the FormIt snippet call into the Resource that contains the form you want to use.
But…how do I do that? I have installed Formit, FormDataManager, mtChaptcha, JSON Form Builder, HumanPresence and NoSpam.

Can you explain how I have to go on at a low knowledge level? :slight_smile:
Thanks.

Maybe this post helps:

Thanks for the link. I posted the 2nd form example, enabled SMTP with valid credentials and also posted that quickemail test. I got error messages:

System Settings (used if property is missing):
emailsender System Setting: Turn on Javascript!
site_name System Setting: [Site name]
Properties (from parameters, property set, or snippet default properties:
Tpl chunk name:
subject:
to:
fromName:
replyTo:
emailSender:
allowHtml: 1
message:
Final Values (actually used when sending email):
subject: Default Subject
to: Turn on Javascript!
fromName: QuickEmail
replyTo: Turn on Javascript!
emailSender: Turn on Javascript!
allowHtml: 1
Message Body: Default Message
Send Failed
Mailer error info: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
Server Debug Information:

2023-09-21 16:06:30 SERVER -> CLIENT: 

SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

The SMTP credentials are correct. And I don’t know why the debugger tells me to turn on JS. It is not turned off. Does the debugger mean, in the browser? Or in Modx?

It looks like you have emo installed. Please surround your QuickEmail snippet call with <!-- emo-exclude --> and <!-- /emo-exclude -->

SMTP connect() failed means that the MODX SMTP system settings are not working.

It looks like you have emo installed. Please surround your QuickEmail snippet call with <!-- emo-exclude --> and <!-- /emo-exclude -->

I did not install emo. It is still downloadable.

SMTP connect() failed` means that the MODX SMTP system settings are not working.

Yeah I think so. But they are correct (Username, passwort, port and server name are the same I use in Thunderbird and work).
The only thing is, I don’t know, if SSL or TLS is used. Tb setting is “SSL/TLS” But I tried both.
But the JS errors, they won’t com from SMTP, will they?

Sorry, the NoSpam Package is a very old fork of my emo Package. I am not sure if this package offers the possibility to exclude sections in the page code from processing. You can switch to the emo package, which is actively maintained.

I deleted/deinstalled the noSpam package. Now, I see some more.
The Value emailsender System Setting ,To and sender is now the mail address, which I entered at the MODX installation. For sending out the forms, I would like to use another account, I just created for the formmailer. With a different password. Therefore, that can’t work :wink:

How do I use the SMTP credentials entered in the system setttings for formit but only for formit and continue with the other credentials at the rest of MODX?

I am not sure, if it is possible to use own SMTP settings in Formit. It uses the system settings to send the mails. You can change the from/to with snippet properties.

I changed the base mail address and then I got a Success. Emails get sent via Quickmail. But the part of the form is not sent out:
[[!FormIt?
&hooks=email,redirect
&validate=myfield:required
&redirectTo=1
&emailTpl=myEmailTemplate
&emailSubject=Test Mail
&emailTo=[real mail address]
&emailHtml=0
&submitVar=mySubmit
]]
and I also won’t get a redirect.

Does no one know a soulution? This is essential for my website, I can’t start it without a mailing script.
SMTP seems to work though.

Does the form work correctly without the email hook?
Did you check the MODX error log (in the manager → “Manage” → “Reports” → “Error Log”) to see if something gets logged there when you try to send the form.

yes. I tried one send, and I got this one:
[2023-09-22 20:41:15] (ERROR @ /home/[…]/modx/core/components/formit/src/FormIt/Hook/Email.php : 325) [FormIt] An error occurred while trying to send the email. Message body empty
It says message body empty. But I have entered something:
Bild_043
Although, if the field is really empty, I get “This field is required. my Field” (I can’t attach two images in one post). This does not create an error.

Did you create a chunk with the name “myEmailTemplate” that contains the text to be sent (and some placeholders like [[+myfield]] for the form fields in it)?

Ahhh, that is the reason. Thanks for noticing. I changed it to the standard template, now I get mails.
But the mails only contain:

<p>[[+fields]]</p>

with &emailHtml=0 and

[[+fields]]

with &emailHtml=`1

I would expect to get what I have entered. On the email template, it is exactly this code, I get via email.
But there is a note “The default chunk used for the email. Please do not edit this chunk, as this will be overwritten when updating FormIt.”

So what exactly did you do? Set &emailTpl=`fiDefaultEmailTpl`?
Don’t do this. Either leave the &emailTpl property empty or (much better), create your own chunk with the text and placeholders you want.

Also maybe take a look at the documentation here:
https://docs.modx.com/current/en/extras/formit/formit.hooks/email#usage

I have had enough of this not working crap in the meantime. Why is this so complicated? Why can’t there be a simple form with one page of code insteadt of those 1000 referrers and variables?

I tried SPForm, which was looking easier. But that does not send out emails and sometimes generates white pages. Even at the creators website.

Also, the documentation of MODX/Formit still leaves something to be desired.

Please, I’m not saying anything against you guys. Thanks a lot for your help so far.
I just have invested so much time until now with no result, I will think of changing the contact page to a simple mailto link…

It was very easy when I last had a website. But that is >15 years ago.

So what exactly is the remaining issue with your FormIt form? The email chunk?

Chunks with placeholders in it are a basic part of MODX (and used on every site for various tasks).

With FormIt, every field in your form will become a placeholder in the email chunk (with the name of the form-field as it’s name).
E.g. The field <input type="text" name="message" ...> becomes the placeholder [[+message]].

When you create a chunk with content like this

A website visitor left the following message:
[[+message]]

[[+message]] will get replaced with whatever the user entered into the form field when the email is sent.


There is usually a tradeoff between simplicity and flexibility. In MODX you have full control over the markup of your form and what exactly happens to the data after the form is sent.
If you make “a simple form with one page of code”, people will then start complaining that the form can’t do exactly what they want it to do.

If there are problems with the SPForm extra, then please report them on Github so that they can get fixed.

The documentation of MODX is a community effort. Feel free to improve it by submitting your pull requests to this Github repository.

The MODX community is very small. The people who answer your questions here are very likely to be the same people that create extras, fix bugs in the MODX core code and try to improve the documentation.

If you are struggling with FormIt, can I suggest you start with Formalicious. It provides all the functionality of FormIt and a nice easy to use interface to build the forms with.

https://extras.modx.com/package/formalicious