A Spring Boot project to send and verify email using tokens
- Node.js installed
There are two ways by which you can try this out: Easy way is to use Docker:
docker pull ritish56/spring-email-verification
Then, to run the docker image:
docker run -p 8090:8090 ritish56/spring-email-verification
You also need to start Maildev. To do so, in separate terminal, give command:
docker pull maildev/maildev
Then, run the maildev with the required port:
docker run -p 1025:1025 -p 1080:1080 maildev/maildev
And the second way is to clone the repo if you don't have docker. In terminal:
git clone https://github.com/ritish78/Spring-Email-Verification.git
Then, after this repository is installed. Open the project in IDE using Maven. Then in terminal of IDE,
mvn clean install
Before starting the Spring Boot application, you need to install Maildev. To install Maildev, you can follow their Readme for latest updates or you can follow:
First verify if Node is installed or not. In terminal run:
Node -v
If it shows any version like:
v15.14.1
then, Node is installed properly. If not install Node. If Node is installed then in terminal:
npm install -g maildev
Then, after the installation of maildev, type in terminal:
maildev
Maildev should start on Port 1080. Link
Then, run the Spring Boot application by:
mvn spring-boot:run
Tomcat should start on port 8090.
- Creating a user using Postman. Send a POST request to: http://localhost:8090/api/v1/registration with JSON body of User.
{
"firstName": "Ritish",
"lastName": "Testing",
"email": "ritish78@email.com",
"password": "password"
}
-
Checking the user in database. Here, we are using H2 database. We can see that the user is not enabled by default, as the email verification is not done.
-
In Mail Service, we get an email for confirmation:
-
After the activation of the email is successful, we can see in AppUser table, 'Enabled' column is true for the verified user.