Server-side only
The BosonMail SDK is designed for server-side use. Never expose API keys in browser bundles, mobile apps, or client-side JavaScript. If you need to send email from a browser form, submit the form to your own backend, validate it, and call the SDK server-side.Secret storage
Store API keys in environment variables or a dedicated secrets manager. Validate the key at startup and fail fast if it is missing.lib/bosonmail.ts
Do not log credentials
TheBosonMailClient instance exposes apiKey as a readonly public property. Avoid logging the client object directly, or redact the key first.
info level. Treat them as sensitive data.
Prevent open relay
If your application accepts user input to determine the recipient or content of an email, protect against abuse:- Authenticate send endpoints: only signed-in or authorized users should trigger emails.
- Fix the recipient server-side: for contact forms, do not let the user supply the
toaddress. Hardcode it or map it from a trusted identifier. - Rate limit: apply per-user or per-IP rate limits on endpoints that send email.
- Use CAPTCHA on public forms to reduce automated abuse.
Sanitize user input
The SDK passessubject through as-is after trimming. Escape or strip user-supplied content before placing it in HTML bodies or subjects.
Attachment safety
- Validate file types and sizes in your application before passing them to the SDK.
- Reject executable file types (
.exe,.bat,.sh) at the application layer. - Scan attachments with an antivirus or content scanner if your use case requires it.
- The SDK enforces a 10 MB per-file and 20 MB total limit, but application-level checks should run first.
HTTPS only
The SDK requiresbaseUrl to be an absolute HTTP(S) URL. Always use https:// in production. The default base URL is https://webmail.bosonware.com/api/v1.
Dependency hygiene
The BosonMail SDK has zero runtime dependencies, which reduces supply-chain risk. Still, follow these practices:- Pin the SDK version in
package.jsonand use lockfiles (package-lock.json,yarn.lock,pnpm-lock.yaml). - Run
npm auditregularly. - Verify the package name exactly:
@bosonware-ent/bosonmail. Typosquatting is a real risk. - Upgrade promptly when security fixes are released. See the Changelog for release notes.
Incident response
If you suspect a key leak or unauthorized usage:- Revoke the key immediately via the dashboard or by contacting support@bosonware.com.
- Rotate to a new key.
- Audit recent sends and status checks for unexpected recipients or content.
- Review application logs for signs of injection or abuse.
Legal and privacy
Next steps
Authentication and API keys
Key scopes, storage, rotation, and leak response.
Troubleshooting
Fix common runtime and configuration issues.
Error codes
Understand every error the SDK can return.
Production best practices
Queues, retries, and safe sending patterns at scale.