How gabriaum/email-service-api works
This is a Spring HTTP email-sending service. A client posts recipient, subject, and body to the mail endpoint; the controller delegates to the application service, which tries configured providers in order, fails over on availability errors, and returns provider/attempt metadata. Functional rejections stop failover and are translated to API errors. The README also documents SendGrid and Mailgun integrations and fallback configuration. Provider-to-service wiring and SendGrid’s outbound request details are not shown in excerpts, so those links are marked unverified.
Main entry points: MailSenderService.java Failover service · MailSenderController.java Mail endpoint · SendGridProvider.java SendGrid provider · MailGunProvider.java Mailgun provider
Components 14
HTTP API
- Mail endpoint
src/main/java/com/gabriaum/uber/infra/web/MailSenderController.java - Health endpoint
src/main/java/com/gabriaum/uber/infra/web/HealthController.java - API error mapping
src/main/java/com/gabriaum/uber/infra/web/MailApiExceptionHandler.java
Mail orchestration
- Failover service
src/main/java/com/gabriaum/uber/application/service/MailSenderService.java - Send service port
src/main/java/com/gabriaum/uber/application/port/in/IMailSenderService.java - Provider port
src/main/java/com/gabriaum/uber/application/port/out/IMailSend.java
Provider integrations
- SendGrid provider
src/main/java/com/gabriaum/uber/infra/provider/SendGridProvider.java - Mailgun provider
src/main/java/com/gabriaum/uber/infra/provider/MailGunProvider.java
Mail contracts and errors
- Email request
src/main/java/com/gabriaum/uber/domain/model/EmailDTO.java - Send response
src/main/java/com/gabriaum/uber/infra/web/dto/MailSendResponseDTO.java - Mail exceptions
src/main/java/com/gabriaum/uber/domain/exception
Other components
- API client
- SendGrid
- Mailgun API
Connections 17
- API client → Mail endpoint: posts email
README.md - Mail endpoint → Email request: accepts
src/main/java/com/gabriaum/uber/infra/web/MailSenderController.java - Mail endpoint → Send service port: delegates to
src/main/java/com/gabriaum/uber/infra/web/MailSenderController.java - Failover service → Send service port: implements
src/main/java/com/gabriaum/uber/application/service/MailSenderService.java - Failover service → Provider port: dispatches through
src/main/java/com/gabriaum/uber/application/service/MailSenderService.java - Failover service → SendGrid provider: tries in order
README.md - Failover service → Mailgun provider: fails over
README.md - SendGrid provider → Provider port: implements
src/main/java/com/gabriaum/uber/infra/provider/SendGridProvider.java - Mailgun provider → Provider port: implements
src/main/java/com/gabriaum/uber/infra/provider/MailGunProvider.java - SendGrid provider → SendGrid: sends via
README.md - Mailgun provider → Mailgun API: posts to
src/main/java/com/gabriaum/uber/infra/provider/MailGunProvider.java - Failover service → Email request: reads
src/main/java/com/gabriaum/uber/application/service/MailSenderService.java - Failover service → Send response: returns
src/main/java/com/gabriaum/uber/application/service/MailSenderService.java - Mail endpoint → Send response: returns
src/main/java/com/gabriaum/uber/infra/web/MailSenderController.java - Failover service → Mail exceptions: throws
src/main/java/com/gabriaum/uber/application/service/MailSenderService.java - API error mapping → Mail exceptions: maps errors
src/main/java/com/gabriaum/uber/infra/web/MailApiExceptionHandler.java - Mail endpoint → API client: returns response
src/main/java/com/gabriaum/uber/infra/web/MailSenderController.java