Troubleshooting

"An error occurred while sending the message" in the PrestaShop contact form

Reviewed on 3 min read formularios errores prestashop

The message An error occurred while sending the message, please try again. shows that the contactform module rejected the submission, but does not by itself identify the cause. In current versions it can appear if the url honeypot field contains data, or if the token is missing, does not match the session or has expired.

Open a fresh copy of the form and run a single test while you inspect the request in the Network tab of the browser tools. Check whether url and token are sent, and note the version of PrestaShop, of the contactform module and of the theme. Some module versions set a 600-second expiry, so a tab left open for longer can also fail.

If the request does not contain those fields, compare the module template with the theme's active override:

/themes/Nombre_Tema/modules/contactform/views/templates/widget/contactform.tpl

The preferred solution is to update the theme or ask its developer for an override compatible with the installed version of contactform. Only if you have confirmed that the override is old and the fields are missing, add the block equivalent to the official template's before the submit button:

<style>
  input[name=url] {
    display: none !important;
  }
</style>
<input type="text" name="url" value="" />
<input type="hidden" name="token" value="{$token|escape:'htmlall':'UTF-8'}" />

Clear the PrestaShop cache and repeat the submission with a freshly loaded page. If the fields were already there, do not change the template: check the exact response, the cookies and the application logs before attributing the failure to the theme.

See the official contactform module template for the installed version.

Cache, session and delivery

Check that a page cache or CDN is not reusing the form with another session's token or an expired one. Test from a freshly loaded page and keep cookies during the submission; do not remove the token validation or the honeypot field to force acceptance.

The block shown only works if that module version provides the token variable to the template. Compare it with the installed version's tag, not just with the repository's dev branch. After the form is accepted, also check where the message goes: passing validation does not guarantee that SMTP delivers it.

You may also find useful

Something wrong or out of date? Tell us and we will review it.