Learn how to send an email using React Email and the AWS SES Node.js SDK.
npm install @aws-sdk/client-ses @react-email/components
.jsx
.tsx
import * as React from 'react'; import { Html, Button } from "@react-email/components"; export function Email(props) { const { url } = props; return ( <Html lang="en"> <Button href={url}>Click me</Button> </Html> ); }
import type { SendEmailCommandInput } from "@aws-sdk/client-ses"; import { render } from '@react-email/components'; import { SES } from '@aws-sdk/client-ses'; import { Email } from './email'; const ses = new SES({ region: process.env.AWS_SES_REGION }) const emailHtml = await render(<Email url="https://example.com" />); const params: SendEmailCommandInput = { Source: 'you@example.com', Destination: { ToAddresses: ['user@gmail.com'], }, Message: { Body: { Html: { Charset: 'UTF-8', Data: emailHtml, }, }, Subject: { Charset: 'UTF-8', Data: 'hello world', }, }, }; await ses.sendEmail(params);