This project consists of a backend asynchronous microservice for sending emails for multiple purposes, from email notifications, user account confirmation, etc.
- Java 17
- Spring Boot
- JavaMail
- JPA / Hibernate
- Maven
- RabbitMQ
- PostgreSQL (ElephantSQL)
- The project has an endpoint for sending email messages from POST requests. This is a synchronous endpoint.
- For sending asynchrnous messages, it is connected to a AMPQ messaging service, that queues messages for sending when the service is available.
# clone repository
git clone https://github.com/pauloerico/ms-email
Add the credentials for the Google SMTP server, RabbitMQ service and ElephantSQL databaseon the application.properties file and you are ready to go!
- Send email
POST http://localhost:8080/sending-email
{
"ownerRef": "referência",
"emailFrom": "sender@email.com",
"emailTo": "recipient@email.com",
"subject": "Email subject",
"text": "Email message here."
}
Based on Michelli Brito's project and video tutorials:
Other references:
- https://mailtrap.io/blog/sending-email-using-java/
- https://www.javatpoint.com/example-of-sending-email-using-java-mail-api-through-gmail-server
Alternative SMTP servers: