← All Guides

How to Send Emails with Express.js

Add transactional email sending to your Express.js application with AISend's API. This guide gets you from zero to sending in under 5 minutes.

1. Install the SDK

Add AISend to your Express project:

npm install aisend

2. Initialize the client

Set up the AISend client with your API key:

import { AISend } from 'aisend';

const aisend = new AISend(process.env.AISEND_API_KEY);

3. Create a send endpoint

Add an email sending route to your Express app:

app.post('/send-email', async (req, res) => {
  const { to, subject, html } = req.body;

  const result = await aisend.emails.send({
    from: 'hello@yourdomain.com',
    to,
    subject,
    html,
  });

  res.json(result);
});

4. Test it

Send a test request:

curl -X POST http://localhost:3000/send-email \
  -H "Content-Type: application/json" \
  -d '{
    "to": "test@example.com",
    "subject": "Test from Express",
    "html": "<p>Hello from Express + AISend!</p>"
  }'

Ready to Start Sending?

1,000 emails/month free. No credit card required.