Gmail API or Azure Communication Services
Email is the transport that powers verification mails, password resets, invites, device-approval alerts and notifications. Configure it once and every feature that needs to send mail just works.
Two providers are supported: the Gmail API (via a Google service-account JSON key) and Azure Communication Services (via a connection string). You pick one; Nucleus abstracts the rest behind a single EmailService.
Provider selection#
Choose which transport sends your mail. Only the matching sub-block needs to be filled in.
1{2 "email": {3 "provider": "gmail",4 "gmail": {5 "enabled": true,6 "json_file_path": "GMAIL_SERVICE_ACCOUNT_JSON",7 "from_email": "[email protected]",8 "from_name": "Acme"9 }10 }11}provider'gmail' | 'azure'OptionalThe active email backend. gmail uses the Gmail API with a service account; azure uses Azure Communication Services. Each feature that sends mail (e.g. register.emailVerification.provider) can also name its provider, but this sets the default.
gmail— Google Workspace Gmail API via a service-account key file.azure— Azure Communication Services via a connection string.
Gmail#
Send through the Gmail API using a Google service account. The service-account JSON key is referenced by file path and must have domain-wide delegation to send as from_email.
gmailobjectOptionalGmail provider configuration.
enabledbooleanOptionalActivate the Gmail transport.
json_file_pathstringOptionalPath to the service-account JSON key file. Treated as sensitive — keep it out of source control and mount it as a secret.
from_emailstringOptionalThe sender address mail is sent as (requires delegated authority).
from_namestringOptionalFriendly display name shown to recipients.
Azure Communication Services#
Send through Azure ACS. The connection string can be a literal value or an env-var name; Nucleus resolves it at startup. Requires the optional @azure/communication-email package.
azureobjectOptionalAzure ACS provider configuration.
enabledbooleanOptionalActivate the Azure transport.
connection_stringstringOptionalACS connection string (literal or env-var name). Sensitive — provide via secret/env.
sender_addressstringOptionalVerified ACS sender address.
from_namestringOptionalFriendly display name shown to recipients.
Under the hood — the EmailService#
Whichever provider you pick is hidden behind one EmailService interface, so every feature that sends mail calls the same method and stays provider-agnostic.
EmailService interfacesendEmail · isAvailableOptionalA provider exposes sendEmail({ to, subject, html, attachments? }) and isAvailable(). Callers (auth flows, the notification email channel) check isAvailable() and no-op cleanly when email isn't configured, rather than throwing — so disabling email never breaks a request.
two implementationsGmail · Azure ACSOptionalGmail authenticates with a service account and sends via the Gmail API; AzureEmailService uses an Azure Communication Services connection string and verified sender. The provider field selects which one is constructed at boot.
one transport, many senderssharedOptionalBecause verification, password reset, invites, new-device alerts and notifications all resolve the same EmailService instance, configuring this one block lights up email across every feature at once.
Related sections