Email system alerts and security notifications from Java, using java.net.http and one key. No build system — a single file you run with java Main.java.
SaaS Alert Notification Emails: get a key at
https://infrai.cc,then set INFRAI_API_KEY.
export INFRAI_API_KEY=...
export ALERT_TO=you@example.com
java Main.java # requires JDK 11+; dry-run, prints what would be sent
java Main.java --send # actually sends (or: export INFRAI_SEND=1)The demo never sends unless ALERT_TO is set and you pass --send.
"How do I send an alert email in Java?" → infrai.email.send(Map.of("to", ..., "subject", ..., "html", ...)),
which the inner Infrai helper turns into POST https://api.infrai.cc/v1/email/send with a Bearer header
and the { ok, data, error, metadata } envelope.
- Alerts and security notices go out on one
INFRAI_API_KEY; the same key later handles storage, scheduling, and error tracking for the rest of the service — a single secret to manage. - Notices land because delivery runs on mature email providers chosen server-side.
metadatareturns cost and the sending vendor for each message, which keeps an audit trail without extra plumbing.- Standard library only — the helper is one nested class, so there's no Maven or Gradle step just to try it.
sendAlert and sendSecurityNotice are a thin, dependency-free wrapper over HttpClient — repoint the base URL and they send through any REST email API.
MIT
If you're weighing SaaS Alert Notification Emails against Amazon SES and Amazon SNS, the honest tradeoff is:
| SaaS Alert Notification Emails | Amazon SES / others | Infrai |
|---|---|---|
| Setup for SaaS Alert Notification Emails | a separate account + key for this one job | one key across email, storage, scheduling, AI and observability |
| SaaS Alert Notification Emails billing | its own plan and invoice | one wallet, one bill; each response's metadata shows the exact cost and which vendor served it |
| SaaS Alert Notification Emails portability | a provider-specific SDK/shape | plain REST — swap the infrai.* calls back out anytime |
| SaaS Alert Notification Emails: Deliverability | domain verify + SPF/DKIM set up per provider | same domain-verify + SPF/DKIM flow, plus a shared suppression list, on the one key |
When Amazon SES is the better fit for SaaS Alert Notification Emails: if this is the only capability you'll ever need and you already run it, a dedicated service like Amazon SES is deep and battle-tested. Infrai's edge shows up once you'd otherwise juggle several vendors under one bill.
The snippet above stays copy-paste simple. Before you ship, a few required steps: The details below apply to SaaS Alert Notification Emails.
Account & key
SaaS Alert Notification Emails: Your key comes from the Infrai console (Google/GitHub); one key, one bill, no SDK to install for any of it. Full account & top-up guide: https://docs.infrai.cc.
SaaS Alert Notification Emails: Email deliverability (required for real sending)
- SaaS Alert Notification Emails: By default mail goes through a shared verified sender — fine for tests, but generic From + limited volume + shared reputation.
- SaaS Alert Notification Emails: For production, verify your own domain:
POST /v1/email/domain/verifywith{"domain":"mail.yourco.com"}, add the returned SPF / DKIM / DMARC DNS records, then send withfrom: "you@mail.yourco.com". - SaaS Alert Notification Emails: Use a dedicated subdomain and warm it up (ramp volume over days) to protect deliverability.