To get a Resend API key and set up your domain for email sending, follow the Resend documentation here.
To use the Resend integration to send transactional emails 1 environment variable is required:
RESEND_API_KEY
- Your Resend API key is found on the Resend API keys page.
Once you configured this API key as an environment variable you can use the two functions to either send plain text emails or React template emails.
To send plain text emails use the following function:
import { sendPlainTextMail } from '@/utils/emails/resend'
await sendPlainTextMail(
'to-email@test.com', // to email address
'from-email@test.com', // from email address - usually an email address from your company
'Subject of email', // email subject
'Email body - hey this is a test email', // plain text body of email
[{ name: 'tag-name', value: 'tag-value' }] // optional tags
)
To send an email using a React component as a template use the following function:
import { sendDemoReactEmail } from '@/utils/emails/resend'
await sendDemoReactEmail(
'to-email@test.com', // to email address
'from-email@test.com', // from email address - usually an email address from your company
'Subject of email', // email subject
... React component props used to populate template
)