Home/Email API/Spring Boot mail

spring-boot-starter-mail, or one REST call

The mail starter wires JavaMail over SMTP into your Spring app: dependency, five properties, a JavaMailSender bean. The alternative is a POST through the RestClient you already have.

Verified By Kam Low, Co-founder · Updated

What the starter actually wires

spring-boot-starter-mail autoconfigures a JavaMailSender from spring.mail.host, port, username, password, and the STARTTLS flag. It is tidy Spring, and it is still SMTP underneath: credentials in config, a protocol conversation per send, and silence after the handoff.

application.ymlthe config tax
spring:
  mail:
    host: smtp.example.com
    port: 587
    username: user
    password: pass
    properties.mail.smtp.starttls.enable: true

The RestClient alternative

Spring 6 ships RestClient; Boot apps already have an HTTP story. One POST replaces the starter, the properties, and the bean.

Java · SpringPOST /v1/my/messages
restClient.post()
  .uri("https://api.nitrosend.com/v1/my/messages")
  .header("Authorization", "Bearer " + apiKey)
  .body(Map.of("from", "[email protected]", "to", "[email protected]",
               "subject", "Welcome", "html", "<p>You're in.</p>"))
  .retrieve();

One credential story instead of five properties: the REST API and the MCP server use the same API key. Your Spring service and the agent that maintains it authenticate with one secret, rotated in one place.

We take key scoping seriously enough that it once broke us in a useful way. A customer connected a least-privilege, mail-send-only key from another provider, and our connection test kept reporting it invalid, because the probe called an endpoint that needed broader permissions. We rewrote the check to validate against an endpoint any valid key can read. A platform that punishes minimum-permission keys is training its users to over-scope, and that fix always belongs on the platform side, never in your credentials.

The same posture runs through the mail path your POST lands on. Our relay keeps TCP 2525 firewall-restricted to the API host, requires TLS and exact SMTP authentication on every connection, HMAC-signs each one-recipient route and MX snapshot, and rejects unsigned or replayed requests. Spring teams that have been burned by a permissive internal relay will know exactly why each of those is there.

Full parameters and responses live in the REST API docs and the API reference.

The trap
Gmail app password
abcd efgh ijkl mnop
✕ 500 emails/day cap
✕ breaks when 2FA settings change
✕ a full-inbox credential in your code
The fix
POST /v1/messages
Authorization: Bearer ns_live_…
✓ scoped API key, revoke anytime
✓ 8,000 free sends, no daily cliff
✓ delivery events you can act on

Go deeper

The starter and the RestClient call above both work, but neither is the deeper point. Describe the send to Claude, Cursor, or Codex and our MCP server drafts and sends it on the same account and key, no application.yml block and no bean to configure.

The dependency-free JDK version: send email with Java. The port you pick matters less than the records behind it, so read SMTP ports alongside SPF, DKIM and DMARC authentication.

FAQ

How do I send email from Spring Boot?

Either spring-boot-starter-mail with SMTP properties and a JavaMailSender, or one RestClient POST to an email API with a bearer token. The API path drops the dependency, the credentials, and adds delivery events.

Do I need spring-boot-starter-mail?

Only if you must send over SMTP. For platform sending, a plain HTTP call through RestClient or WebClient is less configuration and more observable.

First send in thirty seconds.

Simple pricing. Unlimited contacts.

Every plan includes full stack emailing: Flows, Newsletter Campaigns and Transactional Email, plus our NitroWheel LLM and all agent integrations (Claude, ChatGPT, Codex, Cursor and others). Pay for what you send, not who you store.

Daily allowances depend on your plan and sender standing. Strong list, domain and delivery evidence can raise standing, including on day one. Trusted receives the full plan allowance; available email credits, safety checks and delivery pacing still apply.

Free
$0
forever
  • Emails 8,000then 500/mo
  • Email types Transactional & Marketing
  • AI actions 20/mo
  • Contacts Free & Unlimited
  • Brands 3
  • Seats 1
  • Recipients / rolling 24h 100–5,000
  • Email validation Prepaid only
Start free
Ultra
$100
per month
  • Emails 125,000/month
  • AI actions 5,000/mo
  • Brands 10
  • Seats 10 · Domains 10
  • Frontier AI Included
  • Dedicated IP Available
  • Recipients / rolling 24h 1,000–625,000
  • Email validation Prepaid only
Get started
Enterprise
$300
per month
  • AI actions Unlimited
  • Unlimited brands & domains Included
  • SSO / SAML Included
  • 99.9% SLA Included
  • Recipients / rolling 24h Contracted
  • Email validation Prepaid only
Get started

Free forever. No credit card required. See full comparison →