Table of Contents

Class SesEmailService

Namespace
Builvero.Infrastructure.Services
Assembly
Builvero.Infrastructure.dll

Implementation of IEmailService using AWS SES for sending email verification codes.

public class SesEmailService : IEmailService
Inheritance
SesEmailService
Implements
Inherited Members

Remarks

This service sends email verification codes using AWS SES. Templates are rendered from embedded resources before sending.

Constructors

SesEmailService(ISesClient, IOptions<SesOptions>, ILogger<SesEmailService>)

Initializes a new instance of the SesEmailService class.

public SesEmailService(ISesClient sesClient, IOptions<SesOptions> sesOptions, ILogger<SesEmailService> logger)

Parameters

sesClient ISesClient

The SES client for sending emails.

sesOptions IOptions<SesOptions>

SES configuration options.

logger ILogger<SesEmailService>

Logger for recording email operations and errors.

Methods

SendVerificationCodeAsync(string, string, string, string, CancellationToken)

Sends an email verification code to a user's email address.

public Task SendVerificationCodeAsync(string email, string code, string fullName, string verifyUrl, CancellationToken cancellationToken = default)

Parameters

email string

The recipient email address. Must be a valid email format.

code string

The 6-digit verification code to send.

fullName string

The recipient's full name for personalization.

verifyUrl string

The link the user should click to verify their email.

cancellationToken CancellationToken

Cancellation token to cancel the operation.

Returns

Task
Implementation of using AWS SES for sending email verification codes.

Remarks

The email includes:

  • Subject: "Verify your Builvero account"
  • HTML content with the verification code
  • Plain text fallback with the verification code
  • Expiration notice (15 minutes)

If the SendGrid API key is not configured, a warning is logged and the method returns without throwing an exception (allows the application to continue in development/test environments).

Exceptions

Exception

Thrown when SendGrid API key is not configured or email sending fails.