Send an email using the builder.
client.EmailSending.Send(ctx, params) (*EmailSendingSendResponse, error)
POST/accounts/{account_id}/email/sending/send
Send an email using the builder.
Security
API Token
The preferred authorization scheme for interacting with the Cloudflare API. Create a token.
Example:
API Email + API Key
The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.
Example:
The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.
Example:
Send an email using the builder.
package main
import (
"context"
"fmt"
"github.com/cloudflare/cloudflare-go"
"github.com/cloudflare/cloudflare-go/email_sending"
"github.com/cloudflare/cloudflare-go/option"
"github.com/cloudflare/cloudflare-go/shared"
)
func main() {
client := cloudflare.NewClient(
option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
)
response, err := client.EmailSending.Send(context.TODO(), email_sending.EmailSendingSendParams{
AccountID: cloudflare.F("account_id"),
From: cloudflare.F[email_sending.EmailSendingSendParamsFromUnion](shared.UnionString("sender@example.com")),
Subject: cloudflare.F("Monthly Report"),
To: cloudflare.F[email_sending.EmailSendingSendParamsToUnion](email_sending.EmailSendingSendParamsToEmailSendingEmailAddressList([]string{"recipient@example.com"})),
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.Delivered)
}
{
"errors": [
{
"code": 0,
"message": "message"
}
],
"messages": [
{
"code": 0,
"message": "message"
}
],
"result": {
"delivered": [
"recipient@example.com"
],
"permanent_bounces": [
"dev@stainless.com"
],
"queued": [
"dev@stainless.com"
]
},
"success": true,
"result_info": {
"count": 0,
"per_page": 0,
"total_count": 0,
"cursor": "cursor",
"page": 0
}
}Returns Examples
{
"errors": [
{
"code": 0,
"message": "message"
}
],
"messages": [
{
"code": 0,
"message": "message"
}
],
"result": {
"delivered": [
"recipient@example.com"
],
"permanent_bounces": [
"dev@stainless.com"
],
"queued": [
"dev@stainless.com"
]
},
"success": true,
"result_info": {
"count": 0,
"per_page": 0,
"total_count": 0,
"cursor": "cursor",
"page": 0
}
}