{"id":22544380,"url":"https://github.com/hardiksinghbehl/spring-boot-freemarker-java-mail-api","last_synced_at":"2025-08-13T23:09:40.303Z","repository":{"id":118947434,"uuid":"372554187","full_name":"hardikSinghBehl/spring-boot-freemarker-java-mail-api","owner":"hardikSinghBehl","description":"POC that sends emails to user on account creation event occurrence: made using java spring boot, apache freemarker, java-mail-API, bootstrap email editor and spring events.","archived":false,"fork":false,"pushed_at":"2021-06-13T09:50:13.000Z","size":85,"stargazers_count":4,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-09T23:51:05.734Z","etag":null,"topics":["apache-freemaker","event-driven-architecture","h2-database","java","java-mail-api","junit5","mockito","openapi3","spring-boot","spring-events"],"latest_commit_sha":null,"homepage":"https://java-mail-freemarker-spring.herokuapp.com/hedwig/swagger-ui.html","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hardikSinghBehl.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-05-31T15:35:13.000Z","updated_at":"2024-10-08T18:15:11.000Z","dependencies_parsed_at":null,"dependency_job_id":"7d088567-6a24-4965-804d-e3ea5ce9e916","html_url":"https://github.com/hardikSinghBehl/spring-boot-freemarker-java-mail-api","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/hardikSinghBehl/spring-boot-freemarker-java-mail-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hardikSinghBehl%2Fspring-boot-freemarker-java-mail-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hardikSinghBehl%2Fspring-boot-freemarker-java-mail-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hardikSinghBehl%2Fspring-boot-freemarker-java-mail-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hardikSinghBehl%2Fspring-boot-freemarker-java-mail-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hardikSinghBehl","download_url":"https://codeload.github.com/hardikSinghBehl/spring-boot-freemarker-java-mail-api/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hardikSinghBehl%2Fspring-boot-freemarker-java-mail-api/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270330595,"owners_count":24565816,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-13T02:00:09.904Z","response_time":66,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apache-freemaker","event-driven-architecture","h2-database","java","java-mail-api","junit5","mockito","openapi3","spring-boot","spring-events"],"created_at":"2024-12-07T14:07:06.956Z","updated_at":"2025-08-13T23:09:40.293Z","avatar_url":"https://github.com/hardikSinghBehl.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Hedwig\n#### Proof-of-concept application to send emails to user on event occurence\n\n[Click Here To Use Running Application](https://java-mail-freemarker-spring.herokuapp.com/hedwig/swagger-ui.html)\n\n## Technologies Used\n* Java Spring Boot\n* JavaMail-API\n* Spring Events\n* Apache Freemarker\n* JPA/H2 in-memory database\n* Lombok\n* Open-API (swagger-ui) \n* [Bootstrap-Email Editor](https://app.bootstrapemail.com/editor)\n\n## Spring Events\n* [Reference Article](https://www.baeldung.com/spring-events)\n* Event classes will represent an event for which a mail has to be sent (account-creation-event in this context can be anything depending on business logic)\n* A listener class that listens to the above created event and executes code whenever the above event occures\n* A publisher will publish the event (notify that event has occurred) and can be injected in the service layer\n* Listener method to be executed asynchronously (recommended)\n\n## Main classes (Drag to new window)\n* [Email-Service](https://github.com/hardikSinghBehl/spring-boot-freemarker-java-mail-api/blob/main/src/main/java/com/hardik/hedwig/mail/service/EmailService.java) (to send emails to provided email-id with provided template and subject)\n* [Account Creation Event](https://github.com/hardikSinghBehl/spring-boot-freemarker-java-mail-api/blob/main/src/main/java/com/hardik/hedwig/mail/event/UserAccountCreationEvent.java)\n* [Account Creation Event Listener](https://github.com/hardikSinghBehl/spring-boot-freemarker-java-mail-api/blob/main/src/main/java/com/hardik/hedwig/mail/listener/UserAccountCreationListener.java) (receives userCreationRequestDto as input and sends mail to provided email-id asynchronously)\n* [User Service](https://github.com/hardikSinghBehl/spring-boot-freemarker-java-mail-api/blob/main/src/main/java/com/hardik/hedwig/service/UserService.java) (class that creates user account in the system and publishes that AccountCreationEvent has occurred)\n\n## Bootstrap Email\n\n* HTML for emails is slightly different from HTML for web\n* Copy the HTML generated from bootstrap email editor (right part of screen) to a .ftl file under **src/main/resources/templates** (configured in FreemarkerConfiguration.class)\n* **account-creation-success.ftl** in templates folder will be generated to the below image\n* ${emailId} and ${fullName} will be converted to provided emailId and fullname with the help of apache freemarker\n\n![mail](https://user-images.githubusercontent.com/69693621/120240895-4fc6dd00-c27f-11eb-9fc5-ef7da9144d5d.png)\n\n## Local Setup\n\n* Install Java 15\n* Install Maven\n\nRecommended way is to use [sdkman](https://sdkman.io/) for installing both maven and java\n\nGo to application.properties and configure your email and [app password](https://devanswers.co/create-application-specific-password-gmail/) (diffrent from regular passwords)\n\n```\nspring.mail.username = \u003cEMAIL-ID-HERE\u003e\nspring.mail.password = \u003cPASSWORD-HERE\u003e\n```\n\nRun the below commands in the core\n\n```\nmvn clean install\n```\n\n```\nmvn spring-boot:run\n```\n\nserver port is configured to 9090 and base-url to /hedwig which can be changed in application.properties file\n\nGo to the below url to view swagger-ui (API docs)\n\n```\nhttp://localhost:9090/hedwig/swagger-ui.html\n```\n\nRun Tests\n\n```\nmvn test\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhardiksinghbehl%2Fspring-boot-freemarker-java-mail-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhardiksinghbehl%2Fspring-boot-freemarker-java-mail-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhardiksinghbehl%2Fspring-boot-freemarker-java-mail-api/lists"}