{"id":32480112,"url":"https://github.com/luizbueno1/spring-email-microservice","last_synced_at":"2026-04-18T19:31:26.797Z","repository":{"id":303447952,"uuid":"1015504578","full_name":"LuizBueno1/spring-email-microservice","owner":"LuizBueno1","description":"A Spring Boot microservice for asynchronous email sending with RabbitMQ integration, MySQL persistence, and comprehensive delivery status tracking.","archived":false,"fork":false,"pushed_at":"2025-07-18T15:52:10.000Z","size":23,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-27T01:51:43.563Z","etag":null,"topics":["email-sender","java","rabbitmq","smtp-mail","spring"],"latest_commit_sha":null,"homepage":"","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/LuizBueno1.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,"zenodo":null}},"created_at":"2025-07-07T15:47:47.000Z","updated_at":"2025-07-18T15:57:26.000Z","dependencies_parsed_at":"2025-07-07T18:03:52.840Z","dependency_job_id":"c61836a5-d688-426a-a115-5ba91be36fe6","html_url":"https://github.com/LuizBueno1/spring-email-microservice","commit_stats":null,"previous_names":["luizbueno1/spring-email-sender","luizbueno1/spring-email-microservice"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/LuizBueno1/spring-email-microservice","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LuizBueno1%2Fspring-email-microservice","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LuizBueno1%2Fspring-email-microservice/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LuizBueno1%2Fspring-email-microservice/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LuizBueno1%2Fspring-email-microservice/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LuizBueno1","download_url":"https://codeload.github.com/LuizBueno1/spring-email-microservice/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LuizBueno1%2Fspring-email-microservice/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31982468,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T17:30:12.329Z","status":"ssl_error","status_checked_at":"2026-04-18T17:29:59.069Z","response_time":103,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["email-sender","java","rabbitmq","smtp-mail","spring"],"created_at":"2025-10-27T01:51:23.750Z","updated_at":"2026-04-18T19:31:26.791Z","avatar_url":"https://github.com/LuizBueno1.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Email Microservice\n\nA robust and scalable email microservice built with Spring Boot that provides asynchronous email sending capabilities through RabbitMQ integration and persistent email tracking.\n\n## Features\n\n- **Asynchronous Email Processing**: Leverages RabbitMQ for message queuing and non-blocking email operations\n- **Email Tracking**: Comprehensive logging and status tracking for all sent emails\n- **RESTful API**: Clean REST endpoints for email management and monitoring\n- **Database Persistence**: Email records stored in MySQL with full audit trail\n- **Validation**: Robust input validation for email data\n- **Pagination Support**: Efficient data retrieval with pagination capabilities\n- **Error Handling**: Comprehensive error handling with detailed status reporting\n\n## Technology Stack\n\n- **Framework**: Spring Boot 3.5.3\n- **Language**: Java 17\n- **Database**: MySQL\n- **Message Broker**: RabbitMQ\n- **Email**: Spring Mail (SMTP)\n- **Validation**: Spring Validation\n- **ORM**: Spring Data JPA\n- **Build Tool**: Maven\n- **Additional**: Lombok, Spring AMQP\n\n## Prerequisites\n\n- Java 17 or higher\n- Maven 3.6+\n- MySQL 8.0+\n- RabbitMQ server\n- Gmail account with App Password (for SMTP)\n\n## Installation and Setup\n\n### 1. Clone the Repository\n```bash\ngit clone \u003crepository-url\u003e\ncd email-microservice\n```\n\n### 2. Database Setup\nCreate a MySQL database:\n```sql\nCREATE DATABASE `ms-email`;\n```\n\n### 3. Environment Configuration\nCreate a `.env` file in the root directory with the following variables:\n```env\nMYSQL_HOST=localhost\nSPRING_MAIL_USERNAME=your-email@gmail.com\nSPRING_MAIL_PASSWORD=your-app-password\nSPRING_RABBITMQ_ADDRESSES=amqp://username:password@host:port/vhost\n```\n\n### 4. Gmail App Password Setup\n1. Enable 2-Factor Authentication on your Gmail account\n2. Generate an App Password: https://support.google.com/accounts/answer/185833\n3. Use the generated App Password in your environment configuration\n\n### 5. RabbitMQ Setup\nSet up a RabbitMQ instance:\n- **Local**: Install RabbitMQ locally\n- **Cloud**: Use CloudAMQP (https://www.cloudamqp.com/) for managed RabbitMQ\n\n### 6. Build and Run\n```bash\n# Build the application\nmvn clean install\n\n# Run the application\nmvn spring-boot:run\n```\n\nThe application will start on `http://localhost:8080`\n\n## API Endpoints\n\n### Send Email\n```http\nPOST /sending-email\nContent-Type: application/json\n\n{\n    \"ownerRef\": \"user123\",\n    \"emailFrom\": \"sender@example.com\",\n    \"emailTo\": \"recipient@example.com\",\n    \"subject\": \"Test Email\",\n    \"text\": \"This is a test email message.\"\n}\n```\n\n### Get All Emails (Paginated)\n```http\nGET /emails?page=0\u0026size=10\u0026sort=emailId,desc\n```\n\n### Get All Emails (Non-Paginated)\n```http\nGET /emails/all\n```\n\n### Get Email by ID\n```http\nGET /emails/{emailId}\n```\n\n## Response Examples\n\n### Successful Email Send\n```json\n{\n    \"emailId\": \"123e4567-e89b-12d3-a456-426614174000\",\n    \"ownerRef\": \"user123\",\n    \"emailFrom\": \"sender@example.com\",\n    \"emailTo\": \"recipient@example.com\",\n    \"subject\": \"Test Email\",\n    \"text\": \"This is a test email message.\",\n    \"sendDateEmail\": \"2024-01-15T10:30:00\",\n    \"statusEmail\": \"SENT\"\n}\n```\n\n### Email List Response\n```json\n{\n    \"content\": [\n        {\n            \"emailId\": \"123e4567-e89b-12d3-a456-426614174000\",\n            \"ownerRef\": \"user123\",\n            \"emailFrom\": \"sender@example.com\",\n            \"emailTo\": \"recipient@example.com\",\n            \"subject\": \"Test Email\",\n            \"text\": \"This is a test email message.\",\n            \"sendDateEmail\": \"2024-01-15T10:30:00\",\n            \"statusEmail\": \"SENT\"\n        }\n    ],\n    \"pageable\": {\n        \"sort\": {\n            \"sorted\": true,\n            \"unsorted\": false\n        },\n        \"pageNumber\": 0,\n        \"pageSize\": 5\n    },\n    \"totalElements\": 1,\n    \"totalPages\": 1,\n    \"last\": true,\n    \"first\": true\n}\n```\n\n## Architecture\n\nThe application follows a clean architecture pattern:\n\n```\n├── configs/          # Configuration classes\n├── controllers/      # REST API controllers\n├── consumers/        # RabbitMQ message consumers\n├── dtos/            # Data Transfer Objects\n├── enums/           # Enumeration classes\n├── models/          # JPA Entity classes\n├── repositories/    # Data access layer\n└── services/        # Business logic layer\n```\n\n## Message Flow\n\n1. **Direct API Call**: Client sends email via REST endpoint\n2. **Queue Processing**: Email messages consumed from RabbitMQ queue\n3. **Email Sending**: SMTP service processes and sends emails\n4. **Status Tracking**: Results stored in database with status updates\n\n## Email Status\n\n- **SENT**: Email successfully delivered\n- **ERROR**: Email failed to send (network issues, invalid credentials, etc.)\n\n## Configuration\n\n### Application Properties\nThe application uses the following key configuration properties:\n\n```properties\n# Server Configuration\nserver.port=8080\n\n# Database Configuration\nspring.datasource.url=jdbc:mysql://${MYSQL_HOST:localhost}:3306/ms-email\nspring.datasource.username=root\nspring.datasource.password=senha123@\n\n# JPA Configuration\nspring.jpa.hibernate.ddl-auto=update\n\n# Email Configuration\nspring.mail.host=smtp.gmail.com\nspring.mail.port=587\nspring.mail.username=${SPRING_MAIL_USERNAME}\nspring.mail.password=${SPRING_MAIL_PASSWORD}\nspring.mail.properties.mail.smtp.auth=true\nspring.mail.properties.mail.smtp.starttls.enable=true\n\n# RabbitMQ Configuration\nspring.rabbitmq.addresses=${SPRING_RABBITMQ_ADDRESSES}\nspring.rabbitmq.queue=ms.email\n```\n\n## Security Considerations\n\n- Use App Passwords instead of regular Gmail passwords\n- Store sensitive configuration in environment variables\n\n### Environment Variables\nEnsure all required environment variables are set in your production environment:\n- `MYSQL_HOST`\n- `SPRING_MAIL_USERNAME`\n- `SPRING_MAIL_PASSWORD`\n- `SPRING_RABBITMQ_ADDRESSES`\n\n### Database Migration\nThe application uses `spring.jpa.hibernate.ddl-auto=update` which automatically creates and updates database tables based on entity changes.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluizbueno1%2Fspring-email-microservice","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fluizbueno1%2Fspring-email-microservice","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluizbueno1%2Fspring-email-microservice/lists"}