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
sesClientISesClientThe SES client for sending emails.
sesOptionsIOptions<SesOptions>SES configuration options.
loggerILogger<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
emailstringThe recipient email address. Must be a valid email format.
codestringThe 6-digit verification code to send.
fullNamestringThe recipient's full name for personalization.
verifyUrlstringThe link the user should click to verify their email.
cancellationTokenCancellationTokenCancellation 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.