The boilerplate includes comprehensive email workflows that automatically handle user communications across authentication, billing, team management, and security scenarios.
Perfect for: Automated user journeys, transactional communications, and professional email sequences that enhance user experience.
The system handles four main categories of email workflows:
Automatic workflows triggered by Better Auth:
// From src/lib/better-auth/auth.ts
sendResetPassword: async ({ user, url }) => {
await createTypedNotificationService({
userId: user.id,
type: NotificationTypeConst.reset_password,
metadata: { url },
})
}reset-password-email.tsx// From src/lib/better-auth/auth.ts
sendVerificationEmail: async ({ user, url }) => {
await createTypedNotificationService({
userId: user.id,
type: NotificationTypeConst.email_verification,
metadata: { url },
})
}verification-email.tsxmagic-link-email.tsx// From src/services/email-service.ts
export const sendSubscriptionCompletedEmailService = async (
subscription: Subscription
) => {
// Process subscription details
const planName = subscription.plan || plan?.planName || 'Plan inconnu'
const price = getFormattedPriceFromSubscription(stripeSubscription)
// Send comprehensive subscription email
}subscription-completed-email.tsx// From src/services/email-service.ts
export const sendSubscriptionUpdatedEmailService = async (
subscription: Subscription
) => {
// Calculate changes and send update email
}subscription-updated-email.tsxsubscription-canceled-email.tsx// From src/services/email-service.ts
export const sendOrganizationInvitation = async ({
email,
invitedByUsername,
invitedByEmail,
teamName,
inviteLink,
}: SendOrganizationInvitationParams) => {
// Send invitation with team context
}invitation-organization-link-email.tsx// Security alerts are critical notifications
await createTypedNotificationService({
userId: user.id,
type: NotificationTypeConst.security_alert,
title: 'Suspicious login detected',
message: 'We detected a login from a new device',
metadata: {
ipAddress: '192.168.1.1',
location: 'Paris, France'
}
})notification-email.tsx with warning stylingThe system automatically handles email priority based on content type:
// From src/services/notification-service.ts
const criticalTypes: NotificationType[] = [
'reset_password',
'email_verification',
'change_email_verification',
'magic_link',
'otp_code',
'security_alert',
'password_changed',
'organization_invitation',
'subscription_created',
'subscription_updated',
'subscription_canceled',
'subscription_deleted',
]These emails are sent regardless of user notification preferences.
These emails respect the user's notification channel settings.
// From src/services/notification-service.ts
try {
// Email sending logic...
} catch (emailError) {
// Don't fail notification creation if email fails
console.error("Erreur lors de l'envoi de l'email de notification:", emailError)
}All workflows automatically adapt to user language preferences:
// From src/services/email-service.ts
const t = await getTranslations({
locale: userLanguage,
namespace: 'email.user.notification',
})Supported languages: French, English, Spanish
Complete email automation! Your application handles all user communication workflows automatically with professional templates and reliable delivery.