Learn how to send an email using React Email and Nodemailer.
npm install nodemailer @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 { render } from '@react-email/components'; import nodemailer from 'nodemailer'; import { Email } from './email'; const transporter = nodemailer.createTransport({ host: 'smtp.forwardemail.net', port: 465, secure: true, auth: { user: 'my_user', pass: 'my_password', }, }); const emailHtml = await render(<Email url="https://example.com" />); const options = { from: 'you@example.com', to: 'user@gmail.com', subject: 'hello world', html: emailHtml, }; await transporter.sendMail(options);