Skip to content

Email Infrastructure Backend Implementation

Email infrastructure supplies provider adapters, transport configuration, templates, and secrets. Feature pages own when and why messages are sent.

Current Integrations

Adonis Mail and Resend

Resend is the default Adonis Mail transport. Two features currently use it:

  • Newsletter signup calls ResendService.sendWelcomeEmail() and awaits delivery.
  • Better Auth's password-reset callback starts a direct mail.send() and logs delivery failure.

ResendService is a narrow adapter around the newsletter welcome template:

typescript
export class ResendService {
  static async sendWelcomeEmail(email: string): Promise<void>
}

Brevo Contacts

BrevoService manages contact creation for newsletter membership:

typescript
export class BrevoService {
  static async addSubscriber(email: string, listId: number): Promise<void>
}

The adapter creates contacts with updateEnabled: false, maps Brevo's duplicate response to DuplicateSubscriberError, and rethrows other provider failures to its caller.

Templates

text
apps/server/resources/views/emails/
└── welcome.edge          # Newsletter welcome email

The password-reset callback builds escaped HTML in apps/server/app/lib/auth.ts; it does not use the newsletter template. The callback escapes the user's display name before interpolation.

Configuration

apps/server/start/env.ts validates these server-only values:

bash
RESEND_API_KEY=your_resend_api_key
RESEND_FROM_NAME=Jubiloop Team
RESEND_FROM_EMAIL=noreply@jubiloop.ca

BREVO_API_KEY=your_brevo_api_key
BREVO_NEWSLETTER_SUBSCRIBER_LIST_ID=your_list_id

Each deployment supplies its own credentials, list ID, and sender identity. Keep real values in the approved secret store and never expose them to browser code, logs, documentation, or issue reports.

Feature Integration

Operations

The application has no email-specific health endpoint, delivery analytics store, queue, automatic retry policy, or fallback transport. Use provider dashboards for account and delivery diagnostics. Direct API checks require approved development credentials.

bash
curl -H "Authorization: Bearer $RESEND_API_KEY" https://api.resend.com/domains
curl -H "Authorization: Bearer $BREVO_API_KEY" https://api.brevo.com/v3/contacts

Redis supports Better Auth runtime storage; it is not an email queue. Routine unit and functional tests stub provider boundaries and must not send live messages.

Built with ❤️ by the Jubiloop team