Install bavimail, create a client with your API key, and call client.emails.send() from an Express route. Every snippet below ran against the live Bavimail API on October 15, 2026, with bavimail 0.3.7 and Express 5.3.0. Bavimail email is live, with a free plan.
What you need
- A Bavimail account. Start free, no credit card.
- A verified domain with at least one address on it. See domains.
- An API key from the dashboard.
- Node.js 18 or later.
1. Install the SDK and set your key
npm install express bavimail
export BAVIMAIL_API_KEY=your_api_keyThe examples use ES modules, so set "type": "module" in package.json.
2. Find the address to send from
Each address on your domain is an alias with an id. emails.send() takes the id.
import { Bavimail } from 'bavimail'
const client = new Bavimail({ apiKey: process.env.BAVIMAIL_API_KEY })
for (const alias of await client.aliases.list()) {
console.log(alias.id, alias.fullEmail)
}Set the id of the address you want as BAVIMAIL_ALIAS_ID.
3. Send from an Express route
The route emails the signed-in user's own address, never an address from the request. A route that emails whatever address it's given lets anyone who finds it send mail from your account.
import express from 'express'
import { Bavimail } from 'bavimail'
const app = express()
// Add your auth middleware here (Passport or a session library). It sets req.user.
const client = new Bavimail({ apiKey: process.env.BAVIMAIL_API_KEY })
function requireUser(req, res, next) {
if (!req.user?.email) return res.status(401).json({ error: 'Sign in first' })
next()
}
app.post('/welcome', requireUser, async (req, res) => {
const email = await client.emails.send({
aliasId: process.env.BAVIMAIL_ALIAS_ID,
toEmail: req.user.email,
subject: 'Welcome aboard',
body: '<p>Thanks for signing up.</p>',
})
res.json({ id: email.id, status: email.status })
})
app.listen(3000, () => console.log('Listening on http://localhost:3000'))Call it from your app once the user has signed in, for example right after sign-up. It returns the email id and queued. A request without a signed-in user gets a 401 and sends nothing. Also limit how often one user can call it, for example with express-rate-limit, so a single account can't use up your daily sending.
4. Check delivery
import { Bavimail } from 'bavimail'
const client = new Bavimail({ apiKey: process.env.BAVIMAIL_API_KEY })
const email = await client.emails.get('EMAIL_ID')
console.log(email.status)In our test it returned delivered within 12 seconds of the send.
5. Read replies
import { Bavimail } from 'bavimail'
const client = new Bavimail({ apiKey: process.env.BAVIMAIL_API_KEY })
const replies = await client.inboundEmails.list({
aliasId: process.env.BAVIMAIL_ALIAS_ID,
limit: 10,
})
for (const message of replies) {
console.log(message.providerReceivedAt, message.fromEmail, message.subject)
}To get replies as they arrive instead of polling, use webhooks.
What it costs
The free plan sends 6,000 emails a month, at most 200 a day, with no card. Developer is US$5 a month for 50,000 emails (pricing).
- Free6,000
- Developer$5 a month50,000
- Startup$50 a month300,000
- Scale$500 a month2,500,000
The same steps in Python are in Send email with Python.
