Skip to content
  • Our Product
    • Namazu Elements
      • What is Elements?
      • Why open source?
      • Docs
        • Namazu Elements in Five Minutes or Less
        • RESTful APIs Library
        • Security Model
        • Accessing the Web UI (CMS)

    Our Product

    A logomark with three layered rhombuses adorning the lettermark that says Elements in bold all-caps sans-serif letters.
    • What is Namazu Elements? Discover our easy-to-use backend network solution built for online games. Rapidly enables full-scale multiplayer games or online solo adventures.
    • Why open source? Is there a truly open source server backend for connected games? There is now. Download and run a local copy of Namazu Elements and try it for yourself.
    Download Namazu Elements

    Get started

    • Quick start Read our Elements 5-minute quick start guide
    • Documentation Read our developer docs for learning more about Elements
    • RESTful APIs A full list of core API specs for working with the Elements framework
    • Security An overview of the server-authoritative security model of Elements
    • Accessing the CMS Manage your game with ease via the Namazu Elements CMS.

    Co-development Reimagined

    • Best real-time game backends in 2026 If you're researching an alternative to your current backend solution, we've prepared a report of all of the backend solutions on the market in 2026 and how Namazu Elements compares.
      Co-dev

    Recent Posts

    • The watercolor-styled Namazu Studios logo over a giant namazu lurking in the depth
      Namazu Studios Featured in San Diego Business Journal
      22 Sep 2025 Press
    • Namazu Elements 3.1 Released – Service Layer Fixes, Secure APIs, and Steam Bug Fix
      22 Apr 2025 Release Notes
  • Case Studies
  • About Us
  • News
  • Services
  • Book a call
namazu-studios-logo
Book a call

Getting Started

  • Namazu Elements in Five Minutes or Less
  • Accessing the Web UI (CMS)
  • CMS Feature Overview

Fundamentals

  • Why You Need a Server (and What “Authoritative” Means)
  • Elements as a Game Runtime
  • Where Your Authoritative Code Runs
  • Lifecycles and Flows

General Concepts

  • Overview
  • Custom Elements
  • Data Models
  • Security Model
  • N-Tier Architecture

Namazu Elements Core Features

  • User Authentication / Sign In
    • What is a User?
    • User Authentication in Elements
    • Email Verification
    • Auth Schemes
      • Auth Schemes
      • OAuth2
      • OIDC
  • Features
    • Applications
    • Sessions
    • Users and Profiles
    • Digital Goods
    • Progress and Missions
    • Progress and Missions (3.4+)
    • Leaderboards
    • Matchmaking – Comprehensive Guide
    • Followers
    • Friends
    • Product Bundles and SKUs
    • Receipts
    • Item Ledger
    • Reward Issuances
    • Save Data
    • Metadata
    • Metadata (3.4+)
    • Email Service
    • Queries
    • Web3
      • Wallets
      • Vaults
      • Omni Chain Support
      • Smart Contracts
        • Smart Contracts
  • Queries
    • Advanced Operators
    • Object Graph Navigation
    • Boolean Queries
    • Base Query Syntax
  • Advanced Operators
    • .name
    • .ref

Your Game Code - Adding Custom Elements

  • Custom Code Overview
  • Windows Setup
  • Mac OS Setup
  • Ubuntu Linux Setup
  • Element Anatomy: A Technical Deep Dive
  • Introduction to Guice and Jakarta in Elements
  • Structuring your Element
  • Events
  • Packaging an Element with Maven
  • Deploying an Element
  • Preparing for code generation
  • Properties
  • Websockets
  • RESTful APIs
  • Direct MongoDB Access (3.5+)

Configuration

  • Matchmaking – Comprehensive Guide
  • Direct Database Access and Batch Configuration
  • Batch Samples
    • Mission Upload Bash Script Sample
    • Item Upload Bash Script Sample

RESTful APIs

  • Importing into Postman
  • RESTful APIs Library
  • Swagger and Swagger UI

Add-Ons

  • Crossplay
    • Namazu Crossfire (Multiplayer)
    • Deploying Namazu Crossfire in your game
  • Roblox
    • Roblox Overview
    • Secure Player Authentication & Registration
    • Global Matchmaking
    • Roblox Security Best Practices

Game Engine & Client Support

  • Unity
    • Elements Unity Plugin
    • Unity Crossfire Plugin

Troubleshooting

  • Common Issues with Docker
  • Local SDK
    • Unable to deploy application : dev.getelements.elements.sdk.exception.SdkElementNotFoundException
    • Could not load class : java.lang.NoClassDefFoundError
  • Namazu Elements Community Edition
    • Common Issues with Docker
    • Unable to deploy application : dev.getelements.elements.sdk.exception.SdkElementNotFoundException
    • Running in the IDE
      • Exception in monitor thread while connecting to server localhost:27017
      • Could not deployAvailableApplications Jetty server Failed to bind to /0.0.0.0:8080 Address already in use

Releases

  • 3.6 Release Notes
  • 3.5 Release Notes
  • 3.4 Release Notes
  • 3.3 Release Notes
  • 3.2 Release Notes
  • 3.1 Release Notes
View Categories
  • Home
  • Docs
  • Namazu Elements Core Features
  • Features
  • Email Service

Email Service

Est. read time: 6 min read

Elements version 3.8+

EmailService is a first-class platform service for sending transactional email via SMTP. It is available to platform code through normal Guice injection and to plugin developers through the standard element injection mechanism.


Interface #

package dev.getelements.elements.sdk.service.email;

public interface EmailService {
    void send(String from, String to, String subject, String body, boolean html);
}
ParameterDescription
fromSender address. Pass null or blank to use the configured DEFAULT_FROM.
toRecipient address.
subjectSubject line.
bodyMessage body – plain text or HTML depending on the html flag.
htmltrue -> text/html 
false -> text/plain

Throws InvalidDataException if SMTP is not configured (i.e. SMTP_HOST is blank).


Platform configuration #

Configure the platform-level SMTP connection via system defines (ELM attributes or JVM properties). These apply to the entire server and to any code running outside an element context.

Constant keyDefaultDescription
dev.getelements.elements.email.smtp.host(blank – disabled)SMTP hostname. Leave blank to disable email at the platform level.
dev.getelements.elements.email.smtp.port587SMTP port.
dev.getelements.elements.email.smtp.starttlstrueEnable STARTTLS.
dev.getelements.elements.email.smtp.user(blank)SMTP username.
dev.getelements.elements.email.smtp.password(blank)SMTP password.
dev.getelements.elements.email.default.from(blank)Default sender address used when from is null.

Example (passing as JVM system properties on startup):

-Ddev.getelements.elements.email.smtp.host=smtp.sendgrid.net
-Ddev.getelements.elements.email.smtp.port=587
-Ddev.getelements.elements.email.smtp.starttls=true
-Ddev.getelements.elements.email.smtp.user=apikey
-Ddev.getelements.elements.email.smtp.password=SG.xxxxx
-Ddev.getelements.elements.email.default.from=noreply@mygame.com

Using EmailService in platform code #

Once SMTP is configured, inject EmailService anywhere in the platform service layer:

import dev.getelements.elements.sdk.service.email.EmailService;
import jakarta.inject.Inject;

public class MyPlatformService {

    private EmailService emailService;

    public void notifyUser(String userEmail, String message) {
        emailService.send(null, userEmail, "Notification", message, false);
    }

    @Inject
    public void setEmailService(EmailService emailService) {
        this.emailService = emailService;
    }
}

For UNSCOPED platform code inject with @Named(Constants.UNSCOPED):

@Inject
public void setEmailService(@Named(Constants.UNSCOPED) EmailService emailService) { ... }

Using EmailService inside a custom Element #

EmailService is bound in the platform Guice injector and is visible to element child injectors. Inject it directly – no additional ELM dependency is needed.

import dev.getelements.elements.sdk.service.email.EmailService;
import jakarta.inject.Inject;

public class WelcomeEmailService {

    private EmailService emailService;

    public void sendWelcome(String toAddress, String displayName) {
        final var body = "<h2>Welcome, " + displayName + "!</h2>"
                       + "<p>Thanks for joining. Good luck out there.</p>";
        emailService.send(null, toAddress, "Welcome to the game!", body, true);
    }

    @Inject
    public void setEmailService(EmailService emailService) {
        this.emailService = emailService;
    }
}

SMTP is configured at the platform level (see above) and shared across all elements.


Graceful degradation #

If SMTP_HOST is blank the service logs a warning and any call to EmailService.send() throws InvalidDataException with the message "Email service is not configured (SMTP_HOST is blank)." – no NPE, no silent failure.

This means you can start the server and configure SMTP later without any crash on startup.

Warning

If DEFAULT_FROM is not configured and null or blank is passed as the from argument, the message will be sent with a blank From header. Most SMTP servers will reject this with a 5xx error. Always set DEFAULT_FROM in production, or ensure every call to send() provides an explicit from address.


See also #

  • Email Verification – built-in email-based UID verification using EmailVerificationService, including token lifecycle, REST endpoints, and custom templates.

Overriding the mail transport (advanced) #

To replace the default SMTP implementation entirely – for example, to use a cloud-native sending SDK – rebind EmailService in your element’s Guice module:

public class MyGameElementModule extends AbstractModule {
    @Override
    protected void configure() {
        bind(EmailService.class).to(MyCustomEmailService.class);
    }
}

MyCustomEmailService implements dev.getelements.elements.sdk.service.email.EmailService and can use any transport mechanism. The binding in the element’s child injector takes precedence over the platform binding for all code within that element.

Email Provider Setup #

This shows how to configure the EmailService SMTP settings for the most common transactional email providers. All providers use the same set of platform configuration keys.


SendGrid #

  1. Sign in to sendgrid.com and go to Settings -> API Keys.
  2. Create an API key with at least the Mail Send permission.
  3. Verify your sender domain or a single sender address under Sender Authentication.
dev.getelements.elements.email.smtp.host=smtp.sendgrid.net
dev.getelements.elements.email.smtp.port=587
dev.getelements.elements.email.smtp.starttls=true
dev.getelements.elements.email.smtp.user=apikey
dev.getelements.elements.email.smtp.password=SG.<your-api-key>
dev.getelements.elements.email.default.from=noreply@yourdomain.com

The SMTP username is always the literal string apikey; the API key itself goes in the password field.


Mailgun #

  1. Sign in to mailgun.com and select or create a Domain.
  2. Under the domain’s SMTP credentials, note the hostname and create or copy an SMTP password for the default postmaster@<domain> user (or create a new SMTP user).
  3. If your domain is in the Mailgun sandbox, add your recipient addresses to the Authorized Recipients list before testing.
dev.getelements.elements.email.smtp.host=smtp.mailgun.org
dev.getelements.elements.email.smtp.port=587
dev.getelements.elements.email.smtp.starttls=true
dev.getelements.elements.email.smtp.user=postmaster@mg.yourdomain.com
dev.getelements.elements.email.smtp.password=<mailgun-smtp-password>
dev.getelements.elements.email.default.from=noreply@yourdomain.com

EU-region accounts should use smtp.eu.mailgun.org as the host.


Amazon SES (SMTP interface) #

  1. In the AWS console, verify your sending domain under Configuration -> Verified identities.
  2. If your account is in the SES sandbox, also verify each recipient address, or submit a production access request to lift the restriction.
  3. Under Account dashboard -> SMTP settings, note the regional SMTP endpoint.
  4. Go to SMTP settings -> Create SMTP credentials to generate an IAM user and download the SMTP username and password (these are not your AWS access keys).
dev.getelements.elements.email.smtp.host=email-smtp.<region>.amazonaws.com
dev.getelements.elements.email.smtp.port=587
dev.getelements.elements.email.smtp.starttls=true
dev.getelements.elements.email.smtp.user=<ses-smtp-username>
dev.getelements.elements.email.smtp.password=<ses-smtp-password>
dev.getelements.elements.email.default.from=noreply@yourdomain.com

Replace <region> with your AWS region, e.g. us-east-1.

SES also supports port 465 (implicit TLS) and port 2587. Port 587 with STARTTLS is the most broadly compatible choice.


Postmark #

  1. Sign in to postmarkapp.com and create or open a Server.
  2. Under API Tokens, copy the Server API token for SMTP auth.
  3. Add and verify your sending domain under Sender Signatures or Domains.
dev.getelements.elements.email.smtp.host=smtp.postmarkapp.com
dev.getelements.elements.email.smtp.port=587
dev.getelements.elements.email.smtp.starttls=true
dev.getelements.elements.email.smtp.user=<server-api-token>
dev.getelements.elements.email.smtp.password=<server-api-token>
dev.getelements.elements.email.default.from=noreply@yourdomain.com

For Postmark, the SMTP username and password are both set to the same server API token.


Generic SMTP server #

Any SMTP relay that supports STARTTLS on port 587 (or port 465 for implicit TLS) works without additional changes. Common examples include self-hosted Postfix/Exim relays and corporate mail gateways.

dev.getelements.elements.email.smtp.host=mail.yourdomain.com
dev.getelements.elements.email.smtp.port=587
dev.getelements.elements.email.smtp.starttls=true
dev.getelements.elements.email.smtp.user=user@yourdomain.com
dev.getelements.elements.email.smtp.password=<password>
dev.getelements.elements.email.default.from=noreply@yourdomain.com

For port 465 (implicit TLS) set starttls=false – the underlying Jakarta Mail session will use smtps transport automatically.


Passing settings at startup #

Settings can be provided as JVM system properties or as environment variables. For containers the environment variable form is usually more convenient:

JVM propertyEnvironment variable
dev.getelements.elements.email.smtp.hostDEV_GETELEMENTS_ELEMENTS_EMAIL_SMTP_HOST
dev.getelements.elements.email.smtp.portDEV_GETELEMENTS_ELEMENTS_EMAIL_SMTP_PORT
dev.getelements.elements.email.smtp.starttlsDEV_GETELEMENTS_ELEMENTS_EMAIL_SMTP_STARTTLS
dev.getelements.elements.email.smtp.userDEV_GETELEMENTS_ELEMENTS_EMAIL_SMTP_USER
dev.getelements.elements.email.smtp.passwordDEV_GETELEMENTS_ELEMENTS_EMAIL_SMTP_PASSWORD
dev.getelements.elements.email.default.fromDEV_GETELEMENTS_ELEMENTS_EMAIL_DEFAULT_FROM

What are your Feelings
Still stuck? How can we help?

How can we help?

Updated on April 16, 2026
Metadata (3.4+)Queries
Table of Contents
  • Interface
  • Platform configuration
  • Using EmailService in platform code
  • Using EmailService inside a custom Element
  • Welcome, " + displayName + "!
  • Graceful degradation
  • See also
  • Overriding the mail transport (advanced)
  • Email Provider Setup
    • SendGrid
    • Mailgun
    • Amazon SES (SMTP interface)
    • Postmark
    • Generic SMTP server
    • Passing settings at startup
  • Documentation
  • Terms of Service
  • Privacy Policy
  • Contact us
  • Linkedin
  • Join our Discord

Namazu Studios LLC is powered by Namazu Elements, an open source modular backend framework for connected games.

Namazu Elements
  • Download
  • About Elements
  • Open source
  • Documentation
  • Support
Namazu Studios
  • Case Studies
  • About Us
  • News
Best realtime game backends 2026
Get in Touch
  • info@namazustudios.com
  • Book a call
  • (619) 862-2890
  • Linkedin
  • Discord

©2008-2026 Namazu Studios. All Rights Reserved.