This is a simple snippet to create a wordpress contact form that sends email using mailgun api.
. Install the mailgun plugin for wordrpess https://wordpress.org/plugins/mailgun/
. Add the config constants to your wp-config.php
. In the worpess admin, create a page and a template for that page, see page-contact.php
(https://codex.wordpress.org/Template_Hierarchy)
. Add the functions to send the email csrf
, json_result
, contact_email
.
-
return actual http status: The way it is right now, all messages will return http status 200, although the json status field will be 500 when errors occur.
-
return correct http status: The way it is right now, the error messages are all 500 instad of the correct ones.
-
handle the ajax error the way it is right now, it is not handling the ajax errors.