Skip to main content

Send

Sends an email with the given parameters.
func (s *EmailsSvcImpl) Send(params *SendEmailRequest) (*SendEmailResponse, error)

Parameters

params
*SendEmailRequest
required
The email parameters

Returns

response
*SendEmailResponse

Example

package main

import (
	"fmt"
	"github.com/resend/resend-go/v3"
)

func main() {
	client := resend.NewClient("re_123456789")

	params := &resend.SendEmailRequest{
		From:    "[email protected]",
		To:      []string{"[email protected]"},
		Subject: "Hello from Golang",
		Text:    "hello world",
		Cc:      []string{"[email protected]"},
		Bcc:     []string{"[email protected]"},
		ReplyTo: "[email protected]",
	}

	sent, err := client.Emails.Send(params)
	if err != nil {
		panic(err)
	}
	fmt.Printf("Email sent: %s\n", sent.Id)
}

SendWithContext

Sends an email with the given parameters and context.
func (s *EmailsSvcImpl) SendWithContext(ctx context.Context, params *SendEmailRequest) (*SendEmailResponse, error)

Parameters

ctx
context.Context
required
Context for the request.
params
*SendEmailRequest
required
The email parameters. See Send for field details.

Returns

response
*SendEmailResponse
See Send for response details.

Example

package main

import (
	"context"
	"fmt"
	"github.com/resend/resend-go/v3"
)

func main() {
	ctx := context.Background()
	client := resend.NewClient("re_123456789")

	params := &resend.SendEmailRequest{
		From:    "[email protected]",
		To:      []string{"[email protected]"},
		Subject: "Hello from Golang",
		Text:    "hello world",
	}

	sent, err := client.Emails.SendWithContext(ctx, params)
	if err != nil {
		panic(err)
	}
	fmt.Printf("Email sent: %s\n", sent.Id)
}

SendWithOptions

Sends an email with the given parameters, context, and additional options.
func (s *EmailsSvcImpl) SendWithOptions(ctx context.Context, params *SendEmailRequest, options *SendEmailOptions) (*SendEmailResponse, error)

Parameters

ctx
context.Context
required
Context for the request.
params
*SendEmailRequest
required
The email parameters. See Send for field details.
options
*SendEmailOptions
required
Additional options for sending the email.

Returns

response
*SendEmailResponse
See Send for response details.

Example

package main

import (
	"context"
	"fmt"
	"github.com/resend/resend-go/v3"
)

func main() {
	ctx := context.Background()
	client := resend.NewClient("re_123456789")

	params := &resend.SendEmailRequest{
		From:    "[email protected]",
		To:      []string{"[email protected]"},
		Subject: "Hello from Golang",
		Text:    "hello world",
	}

	options := &resend.SendEmailOptions{
		IdempotencyKey: "unique-idempotency-key",
	}

	sent, err := client.Emails.SendWithOptions(ctx, params, options)
	if err != nil {
		panic(err)
	}
	fmt.Printf("Email sent: %s\n", sent.Id)
}

Build docs developers (and LLMs) love