Mail Service

The Mail Service provides email sending capabilities across your organization’s applications, allowing users to send emails through a unified API. The service supports various email templates for different use cases such as login OTP, password reset, account creation, user invitations, and suspicious activity alerts.

Architecture Overview

The Mail Service is built on a Node.js backend with MongoDB for data persistence. It leverages configurable SMTP settings to send emails through various providers. The service integrates with other components such as:

  • IAM Service - Handles user authentication and authorization
  • Configuration Manager - Manages SMTP settings
  • Token Manager - Provides JWT authentication

Data Models

Mail Info

Mail Info represents sent emails with their metadata:

  • Subject, sender, and recipients information
  • Email template type used
  • Timestamps for tracking

SMTP Configuration

SMTP Configuration contains the settings required to connect to an email service:

  • Host and port information
  • Authentication credentials
  • Default sender email address

Email Templates

The Mail Service supports various email templates for different use cases:

  • Login with OTP - Sends one-time passwords for authentication
  • Reset Password - Sends password reset links
  • Account Creation - Welcomes new users to the platform
  • App User Invite - Invites users to join the platform
  • Suspicious Login Attempt - Alerts users of potential security threats

Mail API

The Mail API enables sending emails through a unified interface with templating support.

Send Email

Sends an email using the configured SMTP settings and specified template.

POST /api/v1/emails/sendEmail

Update SMTP Configuration

Updates the SMTP configuration used for sending emails.

POST /api/v1/updateSmtpConfig

Authentication

The Mail Service supports two authentication methods:

  1. User Token Authentication - For standard user operations
  2. Scoped Token Authentication - For service-to-service communication

Token Scopes

The following token scopes are used for the Mail Service:

  • SEND_MAIL - Required to send emails
  • FETCH_CONFIG - Required to update SMTP configuration

Schema Definitions