## Send an email
`client.EmailSending.Send(ctx, params) (*EmailSendingSendResponse, error)`
**post** `/accounts/{account_id}/email/sending/send`
Send an email for the specified account using the structured builder. Provide the sender, recipients, subject, and at least one of text or html; attachments are optional.
### Parameters
- `params EmailSendingSendParams`
- `AccountID param.Field[string]`
Path param: Identifier of the account.
- `From param.Field[EmailSendingSendParamsFromUnion]`
Body param: Sender email address. Either a plain string or an object with address and name.
- `UnionString`
- `type EmailSendingSendParamsFromEmailSendingEmailAddressObject struct{…}`
- `Address string`
Email address (e.g., 'user@example.com').
- `Name string`
Display name for the email address (e.g., 'John Doe'). Optional; set to null or leave it unset to send the address on its own.
- `Subject param.Field[string]`
Body param: Email subject line.
- `Attachments param.Field[[]EmailSendingSendParamsAttachment]`
Body param: File attachments and inline images.
- `type EmailSendingSendParamsAttachmentsEmailSendingEmailInlineAttachment struct{…}`
- `Content string`
Base64-encoded content of the attachment.
- `ContentID string`
Content ID used to reference this attachment in HTML via cid: URI (e.g.,
).
- `Disposition EmailSendingSendParamsAttachmentsEmailSendingEmailInlineAttachmentDisposition`
Must be 'inline'. Embeds the attachment in the email body.
- `const EmailSendingSendParamsAttachmentsEmailSendingEmailInlineAttachmentDispositionInline EmailSendingSendParamsAttachmentsEmailSendingEmailInlineAttachmentDisposition = "inline"`
- `Filename string`
Filename for the attachment.
- `Type string`
MIME type of the attachment (e.g., 'image/png', 'text/plain').
- `type EmailSendingSendParamsAttachmentsEmailSendingEmailAttachment struct{…}`
- `Content string`
Base64-encoded content of the attachment.
- `Disposition EmailSendingSendParamsAttachmentsEmailSendingEmailAttachmentDisposition`
Must be 'attachment'. Adds a standard file attachment.
- `const EmailSendingSendParamsAttachmentsEmailSendingEmailAttachmentDispositionAttachment EmailSendingSendParamsAttachmentsEmailSendingEmailAttachmentDisposition = "attachment"`
- `Filename string`
Filename for the attachment.
- `Type string`
MIME type of the attachment (e.g., 'application/pdf', 'text/plain').
- `Bcc param.Field[EmailSendingSendParamsBccUnion]`
Body param: BCC recipient(s). A single email string, a named address object, or an array of either.
- `UnionString`
- `type EmailSendingSendParamsBccEmailSendingEmailAddressObject struct{…}`
- `Address string`
Email address (e.g., 'user@example.com').
- `Name string`
Display name for the email address (e.g., 'John Doe'). Optional; set to null or leave it unset to send the address on its own.
- `type EmailSendingSendParamsBccArray []EmailSendingSendParamsBccArrayUnion`
- `UnionString`
- `type EmailSendingSendParamsBccArrayEmailSendingEmailAddressObject struct{…}`
- `Address string`
Email address (e.g., 'user@example.com').
- `Name string`
Display name for the email address (e.g., 'John Doe'). Optional; set to null or leave it unset to send the address on its own.
- `Cc param.Field[EmailSendingSendParamsCcUnion]`
Body param: CC recipient(s). A single email string, a named address object, or an array of either.
- `UnionString`
- `type EmailSendingSendParamsCcEmailSendingEmailAddressObject struct{…}`
- `Address string`
Email address (e.g., 'user@example.com').
- `Name string`
Display name for the email address (e.g., 'John Doe'). Optional; set to null or leave it unset to send the address on its own.
- `type EmailSendingSendParamsCcArray []EmailSendingSendParamsCcArrayUnion`
- `UnionString`
- `type EmailSendingSendParamsCcArrayEmailSendingEmailAddressObject struct{…}`
- `Address string`
Email address (e.g., 'user@example.com').
- `Name string`
Display name for the email address (e.g., 'John Doe'). Optional; set to null or leave it unset to send the address on its own.
- `Headers param.Field[map[string, string]]`
Body param: Custom email headers as key-value pairs.
- `HTML param.Field[string]`
Body param: HTML body of the email. Provide at least one of text or html (non-empty).
- `ReplyTo param.Field[EmailSendingSendParamsReplyToUnion]`
Body param: Reply-to address. Either a plain string or an object with address and name.
- `UnionString`
- `type EmailSendingSendParamsReplyToEmailSendingEmailAddressObject struct{…}`
- `Address string`
Email address (e.g., 'user@example.com').
- `Name string`
Display name for the email address (e.g., 'John Doe'). Optional; set to null or leave it unset to send the address on its own.
- `Text param.Field[string]`
Body param: Plain text body of the email. Provide at least one of text or html (non-empty).
- `To param.Field[EmailSendingSendParamsToUnion]`
Body param: Recipient(s). Optional if cc or bcc is provided. A single email string, a named address object, or an array of either.
- `UnionString`
- `type EmailSendingSendParamsToEmailSendingEmailAddressObject struct{…}`
- `Address string`
Email address (e.g., 'user@example.com').
- `Name string`
Display name for the email address (e.g., 'John Doe'). Optional; set to null or leave it unset to send the address on its own.
- `type EmailSendingSendParamsToArray []EmailSendingSendParamsToArrayUnion`
- `UnionString`
- `type EmailSendingSendParamsToArrayEmailSendingEmailAddressObject struct{…}`
- `Address string`
Email address (e.g., 'user@example.com').
- `Name string`
Display name for the email address (e.g., 'John Doe'). Optional; set to null or leave it unset to send the address on its own.
### Returns
- `type EmailSendingSendResponse struct{…}`
- `Delivered []string`
Email addresses to which the message was delivered immediately.
- `MessageID string`
Message ID of the sent email.
- `PermanentBounces []string`
Email addresses that permanently bounced.
- `Queued []string`
Email addresses for which delivery was queued for later.
### Example
```go
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"),
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.MessageID)
}
```
#### Response
```json
{
"errors": [
{
"code": 0,
"message": "message"
}
],
"messages": [
{
"code": 0,
"message": "message"
}
],
"result": {
"delivered": [
"recipient@example.com"
],
"message_id": "",
"permanent_bounces": [
"string"
],
"queued": [
"string"
]
},
"success": true,
"result_info": {
"count": 0,
"per_page": 0,
"total_count": 0,
"cursor": "cursor",
"page": 0
}
}
```