A Beginner's Guide to Using Resend

Trust Jamin Trust Jamin
3 min read

As developers, we often include transactional email capabilities in your application to send emails to your users based on actions triggered in your applications, such as account creation/welcome emails, order confirmations, shipping notifications, password reset emails, booking confirmations, receipts and invoices, etc.

Resend is a developer-friendly API you can utilize for sending transactional emails from your application, and due to its ease of integration, it

In this article, we'll explain what resend is, some of its features, and why you should use it as your email provider for your applications.

Introduction

What is Resend?

Resend.com is an email API for developers. It's designed to help developers build, test, and send transactional emails at scale. Resend offers a simple, elegant interface that makes it easy to get started, and it integrates with popular programming languages like JavaScript, PHP, Java, Python, Go, and Ruby.

Resend can be used to send a variety of email types, including welcome emails, password reset emails, and order confirmation emails. It also offers a variety of features to help developers ensure that their emails are delivered successfully, such as email tracking and spam prevention.

Features of Resend

Resend comes with a variety of features that make it stand out from other transactional email services. Let's consider some of them.

Using Resend, you can create email functionalities and send emails using your favorite tools and technologies. At the moment, you can send emails using Resend with popular programming languages and frameworks such as TypeScript, Node.js, PHP, the Laravel framework, Go programming languages, Python, Ruby, and the Rails framework, as well as serverless functions. A few months ago, they added integration and support for sending emails with SMTP, You can read about it here.
They also continually add new integrations for new tools and technologies; most recently, they released a Java SDK, you can read about it here.

Better Debugging and Developer Experience

Resend One cool thing I like about resend is that you can easily test your email functionality in different environments, and the results will remain the same.
Its error handling feature makes it easy for you to handle different scenarios during development when your emails are not going through

With its analytic dashboard, you can easily tell when your emails are getting bounced or throwing errors during production

Email Tracking, Spam Prevention

When creating transactional emails to send from your application, you most times will want to be able to do the following:

  • Track emails to see if they were delivered, opened, or clicked.

Hooks functionality

Webhooks

  • Features to help ensure email delivery, such as email tracking and spam prevention

  • Affordable

  • Once you configure a webhook, you'll be able to receive real-time updates about email events. Add webhook

Examples

NextJs

Install the

npm install resend

as an API

import type { NextApiRequest, NextApiResponse } from 'next';
import { EmailTemplate } from '../../components/EmailTemplate';
import { Resend } from 'resend';

const resend = new Resend(process.env.RESEND_API_KEY);

export default async (req: NextApiRequest, res: NextApiResponse) => {
  try {
    const data = await resend.emails.send({
      from: 'Acme <onboarding@resend.dev>',
      to: ['delivered@resend.dev'],
      subject: 'Hello world',
      react: EmailTemplate({ firstName: 'John' }),
    });

    res.status(200).json(data);
  } catch (error) {
    res.status(400).json(error);
  }
};

Go

install the Resend SDK for Go

go get github.com/resendlabs/resend-go
package main

import "github.com/resendlabs/resend-go"

func main() {
    apiKey = "re_123"

    client := resend.NewClient(apiKey)

    params := &resend.SendEmailRequest{
        From:    "Acme <onboarding@resend.dev>",
        To:      []string{"@test.com"},
        Html:    "<strong>hello world</strong>",
        Subject: "Hello from Golang",
        Cc:      []string{"cc@example.com"},
        Bcc:     []string{"bcc@example.com"},
        ReplyTo: "replyto@example.com",
    }

    sent, err := client.Emails.Send(params)
    if err != nil {
        fmt.Println(err.Error())
        return
    }
    fmt.Println(sent.Id)
}

You can find some other examples on the official Resend documentation

Conclusion

  • Resend is a great email API for developers who need to send transactional emails.

  • It's easy to use, reliable, and affordable.

  • If you're looking for an email API to help you send transactional emails, Resend is a great option

https://resend.com

https://resend.com/docs/introduction

https://react.email

20
Subscribe to my newsletter

Read articles from Trust Jamin directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Trust Jamin
Trust Jamin

Product Engineer and Gustavo of community, building, learning, and unlearning