The Spring Framework provides a helpful utility library for sending email that shields you from the specifics of the underlying mailing system and is responsible for low-level resource handling on behalf of the client.
In this project I have shown how to send a simple email.
For sending mails with attachments you can utilize the MimeMessage Interface and MimeMessageHelper class to compose email with attachments and send.
For more reference visit the official documentation of Spring Mail here