Class LocalEmailService
- Namespace
- Builvero.Infrastructure.Services
- Assembly
- Builvero.Infrastructure.dll
Local email service implementation that logs email verification codes instead of sending them. Used only when BUILVERO_ENV=local.
public sealed class LocalEmailService : IEmailService
- Inheritance
-
LocalEmailService
- Implements
- Inherited Members
Constructors
LocalEmailService(ILogger<LocalEmailService>, string?)
Initializes a new instance of the LocalEmailService class.
public LocalEmailService(ILogger<LocalEmailService> logger, string? emailOutputPath = null)
Parameters
loggerILogger<LocalEmailService>Logger for recording email operations.
emailOutputPathstringOptional path to write email payloads (e.g., "/tmp/emails"). If null, emails are only logged.
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
- Local email service implementation that logs email verification codes instead of sending them. Used only when BUILVERO_ENV=local.
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.