Fix Contact Form 7 “Failed to send your message…”

I updated the Contact From 7 plugin I’m using on this site and then started receiving “Failed to send your message. Please try later or contact administrator by other way.” errors from it. I tried the only fix I could find on the internet which was to change the from e-mail to the same domain as the website, but it didn’t help.

After looking at the code I managed to find what was causing my error, it was the WP-Super Cache plugin I’m using. The contact form plugin generates a unique token for each person who submits the form, presumably to stop CSRF attacks, which was being cached by WP-Super Cache which in turn caused the token to no longer be unique or valid.

Adding /contact/ to the excluded strings in the Advanced section of WP-Super Cache settings solved the problem for me. Hopefully this will help someone else who gets stuck by this error.