# Express Email Quickstart

Source: https://wraps.dev/docs/quickstart/email/express

Quickstart / Express

# Send Email from Express

Deploy email infrastructure and send your first email from an Express application.

Run this quickstart with your AI agent

Paste into Claude Code, Cursor, or any agent with shell access.

Copy promptView

Using Claude Code? Install the Wraps skills for deeper context:

npx add-skill wraps-team/skills

Prerequisites

Before you begin, make sure you have:

-   Node.js 18 or later installed
-   AWS credentials configured ([AWS Setup Guide](https://wraps.dev/docs/guides/aws-setup))
-   A domain you own

## 

1

Deploy Infrastructure

Run the Wraps CLI to deploy email infrastructure to your AWS account:

terminal.sh

```
npx @wraps.dev/cli email init
```

## 

2

Add Your Domain

Add and verify your sending domain with AWS SES:

terminal.sh

```
npx @wraps.dev/cli email domains add -d yourdomain.com
```

DNS Setup

The CLI will output DKIM records to add to your DNS provider. Once added, verify them with `npx @wraps.dev/cli email domains verify -d yourdomain.com`

## 

3

Install the SDK

Install the `@wraps.dev/email` package in your Express project:

terminal.sh

```
npm install @wraps.dev/email
```

## 

4

Create Email Service

Create a singleton email service that reuses AWS connections across requests:

src/services/email.ts

```
import { WrapsEmail } from '@wraps.dev/email';// Create a singleton instance — reuses AWS connectionsexport const email = new WrapsEmail({  region: process.env.AWS_REGION || 'us-east-1',});
```

## 

5

Add a Send Route

Create an Express route that accepts email parameters and sends using the SDK:

src/routes/email.ts

```
import { Router } from 'express';import { email } from '../services/email';const router = Router();router.post('/send', async (req, res, next) => {  try {    const { to, subject, html } = req.body;    const result = await email.send({      from: 'hello@yourdomain.com',      to,      subject,      html,    });    res.json({ success: true, messageId: result.messageId });  } catch (error) {    next(error);  }});export default router;
```

## 

6

Error Handling Middleware

Add error handling middleware to return meaningful error responses for email failures:

src/middleware/error-handler.ts

```
import { SESError, ValidationError } from '@wraps.dev/email';export function emailErrorHandler(err, req, res, next) {  if (err instanceof ValidationError) {    return res.status(400).json({ error: err.message, field: err.field });  }  if (err instanceof SESError) {    const status = err.retryable ? 503 : 400;    return res.status(status).json({ error: err.message, code: err.code });  }  next(err);}
```

Error Types

-   **ValidationError** — Invalid email parameters (missing fields, bad format)
-   **SESError** — AWS SES errors (throttling, bounces, invalid identity)

## Next Steps

Email SDK Reference

Learn about all available methods, options, and advanced features.

[View SDK Docs](https://wraps.dev/docs/sdk-reference)

Error Codes

Reference for all error codes and troubleshooting steps.

[View Errors](https://wraps.dev/docs/reference/errors)

### Need Help?

If you run into any issues, check our GitHub discussions or open an issue.

[Get Help](https://github.com/wraps-team/wraps/discussions)
