resent

package module
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 26, 2026 License: MIT Imports: 9 Imported by: 0

README

Go Reference License Docs

Documentation · Website · pkg.go.dev · GitHub

Resent Go SDK

The official Go library for Resent transactional email.

Install

go get github.com/resentmail/resent-go@v0.1.1

Setup

  1. Verify a sending domain in the Resent dashboard
  2. Create an API key under Settings → API keys
  3. Store it as RESENT_API_KEY
package main

import (
	"context"
	"log"
	"os"

	"github.com/resentmail/resent-go"
)

func main() {
	client, err := resent.New(os.Getenv("RESENT_API_KEY"))
	if err != nil {
		log.Fatal(err)
	}

	result, err := client.Emails().Send(context.Background(), &resent.SendEmail{
		From:    "Acme <noreply@yourdomain.com>",
		To:      []string{"you@example.com"},
		Subject: "Hello World",
		HTML:    "<p>Congrats on sending your <strong>first email</strong> with Resent!</p>",
	})
	if err != nil {
		log.Fatal(err)
	}

	log.Println(result.SubmissionID)
}

Send email using HTML

result, err := client.Emails().Send(ctx, &resent.SendEmail{
	From:    "Acme <noreply@yourdomain.com>",
	To:      []string{"you@example.com"},
	Subject: "Hello World",
	HTML:    "<strong>It works!</strong>",
})

Send email using text

result, err := client.Emails().Send(ctx, &resent.SendEmail{
	From:    "Acme <noreply@yourdomain.com>",
	To:      []string{"you@example.com"},
	Subject: "Hello World",
	Text:    "It works!",
})

Docs

License

MIT © Resent

Documentation

Overview

Package resent is the official Go SDK for Resent transactional email.

client, err := resent.New(os.Getenv("RESENT_API_KEY"))
if err != nil {
    log.Fatal(err)
}
result, err := client.Emails().Send(ctx, &resent.SendEmail{
    From:    "Acme <noreply@yourdomain.com>",
    To:      []string{"you@example.com"},
    Subject: "Hello World",
    HTML:    "<strong>It works!</strong>",
})

Index

Constants

View Source
const DefaultBaseURL = "https://resent.one/api/v1"
View Source
const Version = "0.1.1"

Version is the SDK version string sent in User-Agent.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client talks to the Resent API.

func New

func New(apiKey string, opts ...Option) (*Client, error)

New creates a Resent client. Pass an API key, or leave empty to use RESENT_API_KEY.

func (*Client) Emails

func (c *Client) Emails() *EmailsService

Emails returns the email API namespace.

type EmailsService

type EmailsService struct {
	// contains filtered or unexported fields
}

EmailsService exposes transactional email endpoints.

func (*EmailsService) Send

Send delivers a transactional email.

type Error

type Error struct {
	Message string
	Status  int
	Body    map[string]any
}

Error is returned for validation and API failures.

func (*Error) Error

func (e *Error) Error() string

type Option

type Option func(*Client)

Option configures a Client.

func WithBaseURL

func WithBaseURL(baseURL string) Option

WithBaseURL overrides the API base URL (default: https://resent.one/api/v1).

func WithHTTPClient

func WithHTTPClient(httpClient *http.Client) Option

WithHTTPClient sets a custom HTTP client.

type SendEmail

type SendEmail struct {
	From    string   `json:"from"`
	To      []string `json:"to"`
	Subject string   `json:"subject"`
	HTML    string   `json:"html,omitempty"`
	Text    string   `json:"text,omitempty"`
	CC      []string `json:"cc,omitempty"`
	BCC     []string `json:"bcc,omitempty"`
	ReplyTo string   `json:"reply_to,omitempty"`
}

SendEmail is the request body for POST /email/send.

type SendEmailResponse

type SendEmailResponse struct {
	ID           string `json:"id"`
	SubmissionID string `json:"submission_id"`
	Status       string `json:"status"`
}

SendEmailResponse is returned after a successful send.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL