Table of Contents

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

logger ILogger<LocalEmailService>

Logger for recording email operations.

emailOutputPath string

Optional 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

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
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.