Sending Emails using Resend

Send Emails to your users using Resend in NodeJS in just a couple of few steps.

Resend is an SMTP email service that lets you send emails from your domain. It’s easy to use and has a lot of features that make it a good choice for businesses of all sizes.

Here is how you can send an email using Resend in NodeJS.

  1. Create a Resend account here https://resend.com/ and add your custom domain. You can still use their test domain for test and development.

  2. Folder Overview

    • Server.js is the entry point for our app.

    • app.js configures our application and dependencies for development

    • router defines API endpoints for our application.

    • controllers contain an async function which will be called once our app hits an endpoint.

    • config.env contains API KEYS for Resend Configurations.

  1. Create a NodeJS server using express

    1. Create app.js file and make app configurations

      • Includes setting up the routing for our email endpoint

      • Adding Morgan for logging and setting up our middleware.

    2. Configuring routing

      • Creating a POST route that will be responsible for sending our email to a user.

    3. Creating our controller function to send our email using Resend

      • Install Resend npm package - npm i resend

      • Create a resend client using your generated API KEY

        • new resend.Resend(process.env.RESEND_PASSKEY);
      • Get the data from the res. body such as from(Your custom domain), to, subject and the content of the email.

      • Make the send email using your Resend client to send email.

      • Ensure to catch errors💥

    4. Email will be sent to the user's inbox and Resend will show you on your Dashboard.

Github Repository - github.com/Karumaidoi/Resend-Email