Welcome to the readme file for the EasyContactForms program built with Spring Boot. This application allows you to store or forward contact form submissions via a REST endpoint. Below you will find important information regarding the setup and usage of the program.
The EasyContactForms Backend utilizes a REST endpoint to receive and process form submissions. The endpoint expects a POST request with the necessary fields for the contact form entry. Once a request is received, it will either be stored in a relational database or forwarded to the specified email address.
There are multiple data types accepted by the endpoint including a simple HTML Form as followed.
<form method="post" action="{{host}}/contact">
<!-- minimal accepted request information -->
<label>Email
<input type="email" name="email">
</label>
<br>
<label>Message
<input type="text" name="message">
</label>
<br>
<!-- Redirect information for the server given as hidden input fields -->
<input type="hidden" name="redirect" value="{{urlSuccess}}"/>
<input type="hidden" name="redirectError" value="{{urlError}}"/>
<input type="submit">
</form>
There are some variables used in the snippet which are explained bellow:
- host: Base url of the EasyContactForms server including port
- urlSuccess: redirect url to the static website if action was performed successful
- urlError: redirect url to the static website if action terminated with errors
- Java Version >= 17
- Java Version >= 17
- Gradle Version >= 7
- Docker
Start from jar file:
java -jar EasyContactForms-1.0.0-SNAPSHOT.jar
Compile from source:
-
Ensure that you have Java and Gradle installed on your system.
-
Clone the repository.
-
Navigate to the project directory:
cd EasyContactForms
-
Build the system:
./gradlew build
With jar file:
-
Start the application via terminal/powershell
- this will create all needed directories in the directory of the jar file
- the application will add the default configuration to the config folder
-
Configure the following properties according to your requirements:
- Specify the database connection URL, username, and password for storing the form submissions otherwise they will be stored locally in a file.
- Set the email settings to forward submissions to a particular email address.
- You will need an email account from which this application will send the contact requests to your destination email
-
Set up a proxy (e.g. nginx) or add a ssl certificate to encrypt traffic
- for a selfsigned certificate you can run the make target
sslCertificate
- for a selfsigned certificate you can run the make target
-
You can deactivate redirect to email by setting the configuration option
redirect.mode=email
toredirect.mode=none
If self compiled:
-
Copy the file
example.application.properties
intoapplication.properties
-
Configure the following properties according to your requirements:
- Specify the database connection URL, username, and password for storing the form submissions.
- Set the email settings to forward submissions to a particular email address.
- You will need an email account from which this application will send the contact requests to your destination email
-
Set up a proxy (e.g. nginx) or add a ssl certificate to encrypt traffic
-
You can deactivate redirect to email by setting the configuration option
redirect.mode=email
toredirect.mode=none
-
Open the
dev.application.properties
file located in theconfig
directory. -
If you want to use another database then H2 for development configure it here.
-
Copy the
dev.application.properties
toapplication.properties
-
Run the Make target
sslCertificate
to generate selfsigned certificates for development
-
Start the application:
./gradlew bootRun
-
The application will start on port 8080 by default. If you wish to change the port, update the " application.properties" file accordingly.
-
Send a POST request to the endpoint
http://localhost:8080/contact
with the required form data. Ensure that you include the correct fields and data format. -
It is recommended to set up a proxy server to enable HTTPS. This is needed especially in context of the GDPR(General Data Protection Regulation) of the EU.
Additionally, you will need to start the smtp4dev server over Docker.
docker compose up -d
For insight into the architecture of this application, checkout the docs folder with the API definition and some UML-Diagrams
-
If you encounter any issues during installation or usage of the application, please check the error logs and console output for any error messages or warnings.
-
Verify that all configuration parameters are set correctly, including the database connection and email settings.
To develop a plugin implement the Plugin Interface from the PluginAPI
subproject
You also need to implement the PluginFactory
of this subproject and link it inside your implementation of the Plugin
interface.
Last step is to add the file org.easycontactforms.api.Plugin
with the full name of your Plugin implementation (including package path)
inside the resources/META-INF/services
directory of your Gradle or Maven project.
An example is given in the TestPlugin
subproject.
We welcome contributions to improve this Contact Form Backend program. If you have any suggestions for improvement or have found any issues, please feel free to submit them in the form of pull requests or issues on https://github.com/Jan222333444/EasyContactForms.
This program is licensed under the MIT license and is freely available for personal and commercial use.
For any questions or inquiries, please use the GitHub Issue system of this repository.
Thank you for using EasyContactForms!
© 2023, Jan Korb