Generate static site from WordPress that includes WP Forms and WP Mail SMTP
Question
I build a landing page in WordPress and include a contact form at the bottom, I don’t need all the functions, only the front page and option to leave details for contact me. All the options I’ve found include plugins that worked great, except the WPForms, the contact was broke the page each time I click it.
I really want just to throw to SMTP the mails from contact and no more. Does anyone have any suggestions or deal with that before? I want to keep my site in CloudFront without any instance behaind it.
https://www.reddit.com/r/WordPress/comments/sb3hda/generate_static_site_from_wordpress_that_includes/
Our answer
By definition, if you’re building a static site you won’t have the dynamic capability required to handle forms.
Quoting WP2Static:
Most contact forms for WordPress, whether installed via a plugin or included with your theme or pagebuilder, are dependent on server-side code for submitting the form data. The client (the user’s browser) submits the form data to a PHP script, which handles the mailing…
Not having these server side scripts available is part of the security & performance benefits of going static. But it means we need somewhere else to post our form data.
On a static site you would need an alternative to WP Mail SMTP as the mail hander, and likely also one for WP Forms for form presentation and handling.
Luckily, there are free hosted forms solutions for this, some of which are linked in the link above, such as:
What these services do is, take over your (static) form presentation and (dynamic) form handling. You simply stick a bit of HTML that they provide into your website where you want to present the form, and they handle the rest.