Send Email from Remix
Deploy email infrastructure and send your first email from a Remix application.
Deploy email infrastructure and send your first email from a Remix application.
Before you begin, make sure you have:
Run the Wraps CLI to deploy email infrastructure to your AWS account:
npx @wraps.dev/cli email initAdd and verify your sending domain with AWS SES:
npx @wraps.dev/cli email domains add -d yourdomain.comDNS 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
Install the @wraps.dev/email package in your Remix project:
npm install @wraps.dev/emailCreate a route with a Remix action that sends an email when a form is submitted:
import type { ActionFunctionArgs } from '@remix-run/node';import { json } from '@remix-run/node';import { Form, useActionData } from '@remix-run/react';import { WrapsEmail } from '@wraps.dev/email';const email = new WrapsEmail();export async function action({ request }: ActionFunctionArgs) { const formData = await request.formData(); const to = formData.get('email') as string; const name = formData.get('name') as string; const result = await email.send({ from: 'hello@yourdomain.com', to, subject: `Thanks for reaching out, ${name}!`, html: `<h1>We received your message</h1><p>We'll get back to you soon.</p>`, }); return json({ success: true, messageId: result.messageId });}export default function Contact() { const data = useActionData<typeof action>(); return ( <Form method="post"> <input name="name" placeholder="Your name" required /> <input name="email" type="email" placeholder="Your email" required /> <button type="submit">Send</button> {data?.success && <p>Email sent!</p>} </Form> );}How it works
action function runs on the server when the form is submitteduseActionData gives you the result in the component for UI feedbackDeploy your Remix application using your preferred hosting provider. Set the following environment variables in your deployment configuration:
Environment Variables
AWS_REGION — The AWS region where your infrastructure is deployedAWS_ROLE_ARN — The IAM role ARN for OIDC authentication (or use access keys)Learn about all available methods, options, and advanced features.
View SDK DocsReference for all error codes and troubleshooting steps.
View Errors