26b13f6dbf
New internal service that centralises SMTP email sending. - email-api-models: SendEmailRequest DTO, IEmailApiClient Refit interface, EmailApiSettings - email-api: SmtpEmailDispatcher (MailKit), EmailController (POST /api/email/send), branded HTML shell wrapper, shared-Files-volume attachment support - Protected by X-Internal-Api-Key via UseInternalApiKeyProtection() - No exposed Docker port — internal network only (http://email-api:8080) Closes #22 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
25 lines
740 B
C#
25 lines
740 B
C#
using EmailApi.Models.Requests;
|
|
using EmailApi.Services;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Swashbuckle.AspNetCore.Annotations;
|
|
|
|
namespace EmailApi.Controllers;
|
|
|
|
[ApiController]
|
|
[Route("api/email")]
|
|
public sealed class EmailController : ControllerBase
|
|
{
|
|
private readonly SmtpEmailDispatcher _dispatcher;
|
|
|
|
public EmailController(SmtpEmailDispatcher dispatcher) => _dispatcher = dispatcher;
|
|
|
|
[HttpPost("send")]
|
|
[SwaggerOperation(Summary = "Send an HTML email via SMTP")]
|
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
|
public async Task<IActionResult> Send([FromBody] SendEmailRequest request, CancellationToken ct)
|
|
{
|
|
await _dispatcher.SendAsync(request, ct);
|
|
return NoContent();
|
|
}
|
|
}
|