FormIt not sending - mail function


I’m suddenly getting errors “[FormIt] An error occurred while trying to send the email. Could not instantiate mail function.” for two forms in the same web site.

The forms had been working fine so far. For debugging I reduced the form to the hook ‘email’ only, still the same message. The emailTo-address is of the same domain as the site, there are no special settings for smtp etc. Just FormIt.

I’m using:
MODX 2.8.3
PHP 7.3.30
FormIt 4.2.6

I’m wondering if there is a known issue? Should I ask the provider for recent changes he may have made to their systems? I’m lost a bit …

Thanks for any help!

maybe try smtp instead of php mail function to rule that out?

Thanks for your hint,
I changed to use smtp in the system settings, and also changed PHP to 7.4. Unfortunately still no success …

are you getting a diff error when you change it?

maybe post your code here maybe there is a mistake?

also check error log?

check under system info phpmailer version. you can also test phpmailer by just doing the forgot password option on login, then you know that php mailer is working or not.

if it works it must be an issues with formit, your code or mailer hook

Try the QuickEmail extra with debug turned on to see if you get a better idea of what’s going wrong.

Hi Bob,
thanks for your hint to the QuickEmail Extra - was not aware before.
I’m getting the message:
“Send failed - Mailer error info: Mail-Funktion konnte nicht initialisiert werden.” (Could not be initialized)

With debug mode, I’m getting this:

Properties (from parameters, property set, or snippet default properties:

Tpl chunk name:
allowHtml: 1

Final Values (actually used when sending email):

subject: Default Subject
to: @ 7media . de
fromName: QuickEmail
replyTo: @ 7media . de
emailSender: @ 7media . de
allowHtml: 1
Message Body: Default Message

The empty spaces before and after @ and beforte .de I added here in the reply box for not creating links.

In the error log, there is no entry for this failure. I changed the template to empty, but no change as well.

Not sure, but would be glad if this helps any further …
Thx again

Have you tried using a recipient email address (to:) that is different from the sender email address (emailSender:)?

Hello, yes I did. Thanks for your hint.

Don’t know if this can help: I’m getting a lot of error messages, not related to FormIt or QuickEmail or sending form messages, as far as I see:

"[2021-09-22 15:23:24] (ERROR in xPDO::getService @ …/www/core/xpdo/xpdo.class.php : 1235) modRestClient::__construct is deprecated since version 2.3.0. Use the modRest classes instead.
[2021-09-22 15:23:24] (ERROR in modRestCurlClient::__construct @ …/www/core/model/modx/rest/modrestcurlclient.class.php : 26) modRestClient::__construct is deprecated since version 2.3.0. Use the modRest classes instead.

I removed the detailed path info between @ and …/www/… for this post.

Thx again

Some unrelated deprecation warning is not the problem.

The error message “Could not instantiate mail function.” (“Mail-Funktion konnte nicht initialisiert werden.”) indicates that the mail() function in PHP returns false when sending the mail. Unfortunately it’s unclear why.

Maybe you could try executing this function directly in a snippet and see if you gain more insight this way.

That error is only seen when it tries to use the mail() function, meaning you have not yet configured SMTP sending correctly.

Please make sure you’ve enabled all the right settings and then try again with QuickEmail: Sending mail - Building Sites | MODX Documentation

Thanks Mark,

and to all the other contributors. Changing the mail function to use smtp is working.

As I understand it is better in any case than the PHP mail function.


It’s not uncommon for hosts to disable the mail() function.