Skip to content

Send an email

client.Email.Send(ctx, body) (*EmailSendResponse, error)
POST/v1/emails/send

Sends an email via the connected email account that owns the from address. Currently supports new sends only; replies and forwards are not yet supported.

Supports idempotency via the Idempotency-Key header.

Required scope: emails:create

Rate limit category: Write

ParametersExpand Collapse
body EmailSendParams
From param.Field[string]

Bare email address (no display name). Must match a connected email account owned by the API key user. Compared case-insensitively. Used as the From header when sending.

MessageBody param.Field[EmailSendParamsMessageBody]

Email message body (HTML or plain text).

Content string

Email body content.

minLength1
ContentType stringOptional

Defaults to HTML.

One of the following:
const EmailSendParamsMessageBodyContentTypeHTML EmailSendParamsMessageBodyContentType = "HTML"
const EmailSendParamsMessageBodyContentTypeText EmailSendParamsMessageBodyContentType = "TEXT"
Subject param.Field[string]

Email subject. Cannot be empty.

minLength1
To param.Field[[]string]

Recipient email addresses (bare, no display names). At least 1, at most 500.

Attachments param.Field[[]string]Optional

Optional list of file IDs (uploaded via the Files API) to attach to the email. Maximum 5 attachments per email, each ≤ 3MB.

Bcc param.Field[[]string]Optional

Bcc recipients (same shape as to).

Cc param.Field[[]string]Optional

Cc recipients (same shape as to).

ReturnsExpand Collapse
type EmailSendResponse struct{…}
SentAt string

ISO 8601 timestamp of when the send completed.

Send an email

package main

import (
  "context"
  "fmt"

  "github.com/Lightfld/lightfield-go"
  "github.com/Lightfld/lightfield-go/option"
)

func main() {
  client := githubcomlightfldlightfieldgo.NewClient(
    option.WithAPIKey("My API Key"),
  )
  emailSendResponse, err := client.Email.Send(context.TODO(), githubcomlightfldlightfieldgo.EmailSendParams{
    From: "sales@acme.com",
    MessageBody: githubcomlightfldlightfieldgo.EmailSendParamsMessageBody{
      Content: "<p>Hi there,</p><p>Following up on our chat earlier this week.</p>",
    },
    Subject: "Following up on our chat",
    To: []string{"lead@example.com"},
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", emailSendResponse.SentAt)
}
{
  "sentAt": "sentAt"
}
Returns Examples
{
  "sentAt": "sentAt"
}