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.
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.
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.
Go deeper
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.