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 George Hartley, Co-founder · Updated July 20, 2026

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.

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 dependency-free JDK version: send email with Java.

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.

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

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