Skip to content

Emails

Developing new emails

Turboship comes with react-email installed to help you develop your emails. You can find all the email templates in the packages/email folder.

To start developing your emails, you can run the following command:

bun dev
# or only the emails:
# bun dev --cwd packages/email

This will start the development server on the port 4000 and you can access your emails at http://localhost:4000.

To create a new email, you can create a new file in the templates folder and export the new email component from the packages/email/index.ts file.

Customizing the theme

To customize the theme, you can edit the packages/email/tailwind.config.ts. This file contains the configuration for the TailwindCSS framework used within the emails only.

Sending emails

By default, Turboship uses resend to send emails. To send an email, you can use the following code snippet:

import {resend} from '@/lib/email'
import {MyTemplate} from '@acme/email'
 
await resend?.emails.send({
  to: 'test@example.com',
  from: 'wlad@turboship.dev',
  subject: `My Email Subject`,
  react: <MyTemplate link="http://localhost:3000" />,
})

This will render the MyTemplate component and send it to the user.

Configuring the email provider

After you have created your Resend account, you can configure the domain. To do this, you can go to the Resend dashboard and navigate to the Domain page. Click on the Add Domain button and follow the instructions to configure your domain. You will need to add the given DNS records to your domain. After that, click on the Verify button to verify your domain records. If the verification is successful, you can start sending emails without any risk.