---
title: "Send email from Spring Boot over SMTP"
description: "JavaMailSender properties pointed at Unitpost."
url: https://www.unitpost.com/docs/smtp/spring
section: SMTP
updated: 2026-11-02
---
# Send email from Spring Boot over SMTP

## Connection settings

- **Host**: smtp.unitpost.com
- **Username**: unitpost (always this literal value)
- **Password**: Your Unitpost API key (must carry emails:send)
- **Port (STARTTLS)**: 587 (or 2587 if blocked, or 25)
- **Port (implicit TLS)**: 465 (or 2465 if blocked)
- **Security**: TLS 1.2 or 1.3 (required before AUTH)
- **From address**: Any address on a verified domain

## Send email from Spring Boot over SMTP

> JavaMailSender properties pointed at Unitpost.

Set Spring Mail properties to Unitpost SMTP and send with JavaMailSender. Port 587, STARTTLS, username `unitpost`.

### 1. Set mail properties

```properties
spring.mail.host=smtp.unitpost.com
spring.mail.port=587
spring.mail.username=unitpost
spring.mail.password=${UNITPOST_API_KEY}
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=true
```

### 2. Send with JavaMailSender

```java
MimeMessage message = mailSender.createMimeMessage();
MimeMessageHelper helper = new MimeMessageHelper(message, true);
helper.setFrom("you@yourdomain.com");
helper.setTo("customer@example.com");
helper.setSubject("Hello from Spring");
helper.setText("<p>Sent via SMTP.</p>", true);
mailSender.send(message);
```

### 3. Verify delivery

Check Emails.

## Related

- [Send email from .NET over SMTP](https://www.unitpost.com/docs/smtp/dotnet): MailKit pointed at Unitpost.
- [Set up SMTP for self-hosted Sentry](https://www.unitpost.com/docs/smtp/sentry): mail.* keys in config.yml, SENTRY_MAIL_HOST for the From domain, and a test from the admin Mail page.
- [Configure GitLab to send email over SMTP](https://www.unitpost.com/docs/smtp/gitlab): gitlab_rails['smtp_*'] in /etc/gitlab/gitlab.rb, a reconfigure, then Notify.test_email in the Rails console.
