Skip to content
  • Email: Live

Send email with Node.js and Express

Install the bavimail package, add an Express route that emails the signed-in user, then check delivery and read replies. Code tested against the live API on Oct 15, 2026.

A code sample that sends a welcome email from an Express route with the Bavimail SDK.

Key takeaways

  • Install bavimail with npm, create a client with your API key, and call client.emails.send() from an Express route.
  • The route emails only the signed-in user's own address, never an address from the request, so nobody else can send mail from your account.
  • A new email starts as queued; client.emails.get() shows when it is delivered.
  • Replies come back through client.inboundEmails.list() or, as they arrive, through signed webhooks.

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_key

The 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).

Emails a month on each Bavimail planEach gridline is 10 times the one before.
  1. Free6,000
  2. Developer$5 a month50,000
  3. Startup$50 a month300,000
  4. Scale$500 a month2,500,000

Source: Bavimail pricing, checked October 15, 2026.

The same steps in Python are in Send email with Python.

FAQ

How do I send an email with Node.js?

Install bavimail with npm, set BAVIMAIL_API_KEY, and call client.emails.send() with an alias id, a recipient, a subject and an HTML body.

Is it safe to send email from an Express route?

Only if the route checks who is calling. Send to the signed-in user's own address, never to an address from the request body, and limit how often one user can call it.

Which Node.js versions does the SDK support?

Node.js 18 or later.

How do I know the email was delivered?

Call client.emails.get(id) and read status. A new email starts as queued and moves to delivered.

How much does it cost?

The free plan has 6,000 emails a month and 200 a day, with no credit card. The Developer plan is US$5 a month for 50,000 emails.