Skip to content

Conversation

@dricazenck
Copy link
Collaborator

Summary

  • Implement comprehensive email service using Spring Boot Mail for transactional emails
  • Add REST API endpoints for single and bulk email sending
  • Include comprehensive unit tests with 84%+ code coverage
  • Add environment-based SMTP configuration for all profiles

Changes

Core Implementation:

  • EmailService - Business logic for sending emails via JavaMailSender
  • EmailController - REST endpoints at /api/platform/v1/email
  • EmailRequest - Immutable DTO for email requests with validation
  • EmailResponse - Immutable DTO for email responses
  • EmailSendException - Custom exception for email failures

Features:

  • Single email sending: POST /api/platform/v1/email/send
  • Bulk email sending: POST /api/platform/v1/email/send/bulk
  • HTML and plain text email support
  • CC, BCC, and Reply-To field support
  • Error handling with custom exceptions
  • OpenAPI/Swagger documentation

Configuration:

  • Added Spring Mail dependency to build.gradle.kts
  • SMTP configuration in all application profiles (local, test, memory)
  • Environment variable support: MAIL_USERNAME and MAIL_PASSWORD
  • Default Gmail SMTP settings (port 587, TLS enabled)

Testing:

  • EmailServiceTest - 9 comprehensive unit tests
  • EmailControllerTest - 7 controller tests with MockMvc
  • Code coverage: 84% for email domain package
  • All tests use immutable DTOs with builder pattern

Documentation:

  • Updated CLAUDE.md with email service architecture and usage
  • Added configuration examples and curl commands
  • Documented environment variables and deployment setup

Test Plan

  • All unit tests pass (478 total tests)
  • Email service tests cover success, failure, and edge cases
  • Controller tests validate REST endpoints with authentication
  • Code coverage meets 70% threshold
  • PMD static analysis clean for email service code
  • Gradle build succeeds

Deployment Notes

Environment Variables Required:

  • MAIL_USERNAME - SMTP username (email address)
  • MAIL_PASSWORD - SMTP password (use app password for Gmail)

Gmail Setup:
For Gmail, you need to create an App Password:

  1. Enable 2FA on your Google account
  2. Go to Security > App passwords
  3. Generate a new app password for "Mail"
  4. Use this password as MAIL_PASSWORD

dricazenck and others added 2 commits November 16, 2025 11:48
Update correct URLs to avoid cors problems
Update deployment setup
Use Claude to help with the project
Implement comprehensive email service to support transactional emails for the WCC platform. The service provides RESTful endpoints for sending single and bulk emails with support for HTML content, CC, BCC, and Reply-To fields.

Key features:
- EmailService with JavaMailSender for SMTP operations
- REST endpoints at /api/platform/v1/email
- Immutable DTOs (EmailRequest, EmailResponse) using Lombok @Getter and @builder
- Custom EmailSendException for error handling
- Comprehensive unit tests with Mockito
- Environment-based SMTP configuration (Gmail by default)
- ObjectUtils.isEmpty() for validation
- OpenAPI/Swagger documentation

Configuration requires MAIL_USERNAME and MAIL_PASSWORD environment variables for production deployments.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Make allowedOrigins field final and move @value annotation to constructor parameter to comply with PMD rules for immutable fields and final parameters.

Changes:
- Changed private field to final
- Moved @value annotation from field to constructor parameter
- Made constructor parameter final

This fixes:
- ImmutableField: Field 'allowedOrigins' may be declared final
- MethodArgumentCouldBeFinal: Parameter 'allowedOrigins' is not assigned and could be declared final
@dricazenck dricazenck self-assigned this Nov 16, 2025
@dricazenck dricazenck requested a review from goelsonali January 5, 2026 18:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants