This tutorial will walk you through the steps of creating a Contact Form Example with Spring Boot, FreeMarker and Amazon SES.

What you'll build

What you'll need

Stack

  • Java, Java Mail API
  • Spring Boot
  • FreeMarker
  • HTML, CSS

Init project structure and dependencies

Project structure

├── src
│   └── main
│       ├── java
│       │   └── com
│       │       └── hellokoding
│       │           └── form
│       │               ├── model
│       │               │   ├── MailProperties.java
│       │               │   └── User.java
│       │               ├── service
│       │               │   ├── SESService.java
│       │               │   └── SendingMailService.java
│       │               ├── web
│       │               │   └── FormController.java
│       │               └── WebApplication.java
│       └── resources
│           ├── static
│           │   ├── css
│           │   │   └── main.css
│           │   └── js
│           │       └── main.js
│           ├── templates
│           │   └── form.ftl
│           └── application.properties
└── pom.xml

Project dependencies


Define DTO, Service, Controller and View Template

Data transfer object


Service



Controller


View template


Config and Run

Application Configuration



Make sure updating all macros such as {YOUR_SES_SMTP_HOST} and {YOUR_SES_SMTP_PORT} to your configs


Run the application

Type the following Maven command on the terminal console at the project root directory

mvn clean spring-boot:run

Source code

https://github.com/hellokoding/hellokoding-courses/tree/master/springboot-examples/springboot-freemarker-form-contact