resend

package
v0.86.0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2026 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ConfigEnvPrefix is the prefix applied to environment variables for configuring Resend.
	ConfigEnvPrefix = config.ConfigEnvPrefix + "RESEND_"
)

Variables

View Source
var ErrInvalidEmail = errors.New("email is invalid")

Functions

func HandleWebhook

func HandleWebhook(res http.ResponseWriter, req *http.Request)

HandleWebhook will handle incoming webhook requests from Resend.

func SendTemplatedEmail added in v0.47.0

func SendTemplatedEmail(ctx context.Context, templateID string, options ...EmailOption) error

SendTemplatedEmail sends the template with the given id to the given address, with any additional template options applied.

func UpdateTemplate added in v0.86.0

func UpdateTemplate(ctx context.Context, alias string, options ...TemplateOption) error

UpdateTemplate will update the template with the given alias. If a template with the alias does not exist, it will be created.

Types

type Attachment added in v0.25.0

type Attachment struct {
	Id                 string `json:"id,omitempty"`
	Filename           string `json:"filename,omitempty"`
	ContentType        string `json:"content_type,omitempty"`
	ContentDisposition string `json:"content_disposition,omitempty"`
	ContentId          string `json:"content_id,omitempty"`
}

type Config

type Config struct {
	WebHookSecret string `koanf:"webhooksecret" validate:"required"`
	APIKey        string `koanf:"apikey"        validate:"required"`
	CatchAllEmail string `koanf:"catchallemail" validate:"required,email"`
	AdminEmail    string `koanf:"adminemail"    validate:"required,email"`
}

Config structure.

type EmailOption added in v0.61.0

type EmailOption func(*email)

EmailOption is a functional option to apply to an email.

func Bcc added in v0.61.0

func Bcc(bcc ...string) EmailOption

Bcc option sets the bcc address of an email.

func Cc added in v0.61.0

func Cc(cc ...string) EmailOption

Cc option sets the cc address of an email.

func To added in v0.61.0

func To(to ...string) EmailOption

To option sets the to address of an email.

func WithTag added in v0.61.0

func WithTag(key string, value string) EmailOption

WithTag option applies the given tag to the email.

func WithVariable added in v0.86.0

func WithVariable(key string, value any) EmailOption

WithVariable option assigns a value to the given template variable in the email template.

type EmailRecieved added in v0.25.0

type EmailRecieved struct {
	EmailId     string       `json:"email_id,omitempty"`
	CreatedAt   string       `json:"created_at,omitempty"`
	From        string       `json:"from,omitempty"`
	To          []string     `json:"to,omitempty"`
	Bcc         []string     `json:"bcc,omitempty"`
	Cc          []string     `json:"cc,omitempty"`
	MessageId   string       `json:"message_id,omitempty"`
	Subject     string       `json:"subject,omitempty"`
	Attachments []Attachment `json:"attachments,omitempty"`
}

type ReceivedEmail added in v0.25.0

type ReceivedEmail struct {
	*resend.ReceivedEmail
}

func (*ReceivedEmail) ExtractAttachments added in v0.61.0

func (e *ReceivedEmail) ExtractAttachments(ctx context.Context) ([]*resend.Attachment, error)

ExtractAttachments will extract and return the attachments on the email, if any.

func (*ReceivedEmail) Forward added in v0.61.0

func (e *ReceivedEmail) Forward(ctx context.Context, to ...string) error

Forward will forward the recieved email to the given addresses.

func (*ReceivedEmail) GetBody added in v0.25.0

func (e *ReceivedEmail) GetBody() string

func (*ReceivedEmail) GetFrom added in v0.25.0

func (e *ReceivedEmail) GetFrom() *mail.Address

func (*ReceivedEmail) GetID added in v0.25.0

func (e *ReceivedEmail) GetID() string

func (*ReceivedEmail) GetSubject added in v0.25.0

func (e *ReceivedEmail) GetSubject() string

func (*ReceivedEmail) Timestamp added in v0.25.0

func (e *ReceivedEmail) Timestamp() time.Time

func (*ReceivedEmail) Valid added in v0.25.0

func (e *ReceivedEmail) Valid() error

Valid returns a non-nil error when the ReceivedEmail contains invalid fields.

type TemplateOption added in v0.86.0

type TemplateOption func(*template)

TemplateOption is a functional option applied to a template.

func WithTemplateHTML added in v0.86.0

func WithTemplateHTML(data []byte) TemplateOption

WithTemplateHTML option sets the HTML format of the template.

func WithTemplateName added in v0.86.0

func WithTemplateName(name string) TemplateOption

WithTemplateName option sets the name of the template.

func WithTemplateSubject added in v0.86.0

func WithTemplateSubject(subject string) TemplateOption

WithTemplateSubject option sets the subject of the template.

func WithTemplateText added in v0.86.0

func WithTemplateText(data []byte) TemplateOption

WithTemplateText option sets the text format of the template.

func WithTemplateVariable added in v0.48.0

func WithTemplateVariable(key, dataType, fallback string) TemplateOption

WithTemplateVariable option sets a variable for use within the template.

type WebhookEmailReceieved added in v0.25.0

type WebhookEmailReceieved struct {
	Type      string        `json:"type,omitempty"`
	CreatedAt string        `json:"created_at,omitempty"`
	Data      EmailRecieved `json:"data,omitempty"`
}

Jump to

Keyboard shortcuts

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