1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package ses
4
5import (
6	"context"
7	awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
8	"github.com/aws/aws-sdk-go-v2/aws/signer/v4"
9	"github.com/aws/aws-sdk-go-v2/service/ses/types"
10	"github.com/aws/smithy-go/middleware"
11	smithyhttp "github.com/aws/smithy-go/transport/http"
12)
13
14// Composes an email message and immediately queues it for sending. In order to
15// send email using the SendEmail operation, your message must meet the following
16// requirements:
17//
18// * The message must be sent from a verified email address or
19// domain. If you attempt to send email using a non-verified address or domain, the
20// operation will result in an "Email address not verified" error.
21//
22// * If your
23// account is still in the Amazon SES sandbox, you may only send to verified
24// addresses or domains, or to email addresses associated with the Amazon SES
25// Mailbox Simulator. For more information, see Verifying Email Addresses and
26// Domains
27// (https://docs.aws.amazon.com/ses/latest/DeveloperGuide/verify-addresses-and-domains.html)
28// in the Amazon SES Developer Guide.
29//
30// * The maximum message size is 10 MB.
31//
32// * The
33// message must include at least one recipient email address. The recipient address
34// can be a To: address, a CC: address, or a BCC: address. If a recipient email
35// address is invalid (that is, it is not in the format
36// UserName@[SubDomain.]Domain.TopLevelDomain), the entire message will be
37// rejected, even if the message contains other recipients that are valid.
38//
39// * The
40// message may not include more than 50 recipients, across the To:, CC: and BCC:
41// fields. If you need to send an email message to a larger audience, you can
42// divide your recipient list into groups of 50 or fewer, and then call the
43// SendEmail operation several times to send the message to each group.
44//
45// For every
46// message that you send, the total number of recipients (including each recipient
47// in the To:, CC: and BCC: fields) is counted against the maximum number of emails
48// you can send in a 24-hour period (your sending quota). For more information
49// about sending quotas in Amazon SES, see Managing Your Amazon SES Sending Limits
50// (https://docs.aws.amazon.com/ses/latest/DeveloperGuide/manage-sending-limits.html)
51// in the Amazon SES Developer Guide.
52func (c *Client) SendEmail(ctx context.Context, params *SendEmailInput, optFns ...func(*Options)) (*SendEmailOutput, error) {
53	if params == nil {
54		params = &SendEmailInput{}
55	}
56
57	result, metadata, err := c.invokeOperation(ctx, "SendEmail", params, optFns, addOperationSendEmailMiddlewares)
58	if err != nil {
59		return nil, err
60	}
61
62	out := result.(*SendEmailOutput)
63	out.ResultMetadata = metadata
64	return out, nil
65}
66
67// Represents a request to send a single formatted email using Amazon SES. For more
68// information, see the Amazon SES Developer Guide
69// (https://docs.aws.amazon.com/ses/latest/DeveloperGuide/send-email-formatted.html).
70type SendEmailInput struct {
71
72	// The destination for this email, composed of To:, CC:, and BCC: fields.
73	//
74	// This member is required.
75	Destination *types.Destination
76
77	// The message to be sent.
78	//
79	// This member is required.
80	Message *types.Message
81
82	// The email address that is sending the email. This email address must be either
83	// individually verified with Amazon SES, or from a domain that has been verified
84	// with Amazon SES. For information about verifying identities, see the Amazon SES
85	// Developer Guide
86	// (https://docs.aws.amazon.com/ses/latest/DeveloperGuide/verify-addresses-and-domains.html).
87	// If you are sending on behalf of another user and have been permitted to do so by
88	// a sending authorization policy, then you must also specify the SourceArn
89	// parameter. For more information about sending authorization, see the Amazon SES
90	// Developer Guide
91	// (https://docs.aws.amazon.com/ses/latest/DeveloperGuide/sending-authorization.html).
92	// Amazon SES does not support the SMTPUTF8 extension, as described in RFC6531
93	// (https://tools.ietf.org/html/rfc6531). For this reason, the local part of a
94	// source email address (the part of the email address that precedes the @ sign)
95	// may only contain 7-bit ASCII characters
96	// (https://en.wikipedia.org/wiki/Email_address#Local-part). If the domain part of
97	// an address (the part after the @ sign) contains non-ASCII characters, they must
98	// be encoded using Punycode, as described in RFC3492
99	// (https://tools.ietf.org/html/rfc3492.html). The sender name (also known as the
100	// friendly name) may contain non-ASCII characters. These characters must be
101	// encoded using MIME encoded-word syntax, as described in RFC 2047
102	// (https://tools.ietf.org/html/rfc2047). MIME encoded-word syntax uses the
103	// following form: =?charset?encoding?encoded-text?=.
104	//
105	// This member is required.
106	Source *string
107
108	// The name of the configuration set to use when you send an email using SendEmail.
109	ConfigurationSetName *string
110
111	// The reply-to email address(es) for the message. If the recipient replies to the
112	// message, each reply-to address will receive the reply.
113	ReplyToAddresses []string
114
115	// The email address that bounces and complaints will be forwarded to when feedback
116	// forwarding is enabled. If the message cannot be delivered to the recipient, then
117	// an error message will be returned from the recipient's ISP; this message will
118	// then be forwarded to the email address specified by the ReturnPath parameter.
119	// The ReturnPath parameter is never overwritten. This email address must be either
120	// individually verified with Amazon SES, or from a domain that has been verified
121	// with Amazon SES.
122	ReturnPath *string
123
124	// This parameter is used only for sending authorization. It is the ARN of the
125	// identity that is associated with the sending authorization policy that permits
126	// you to use the email address specified in the ReturnPath parameter. For example,
127	// if the owner of example.com (which has ARN
128	// arn:aws:ses:us-east-1:123456789012:identity/example.com) attaches a policy to it
129	// that authorizes you to use feedback@example.com, then you would specify the
130	// ReturnPathArn to be arn:aws:ses:us-east-1:123456789012:identity/example.com, and
131	// the ReturnPath to be feedback@example.com. For more information about sending
132	// authorization, see the Amazon SES Developer Guide
133	// (https://docs.aws.amazon.com/ses/latest/DeveloperGuide/sending-authorization.html).
134	ReturnPathArn *string
135
136	// This parameter is used only for sending authorization. It is the ARN of the
137	// identity that is associated with the sending authorization policy that permits
138	// you to send for the email address specified in the Source parameter. For
139	// example, if the owner of example.com (which has ARN
140	// arn:aws:ses:us-east-1:123456789012:identity/example.com) attaches a policy to it
141	// that authorizes you to send from user@example.com, then you would specify the
142	// SourceArn to be arn:aws:ses:us-east-1:123456789012:identity/example.com, and the
143	// Source to be user@example.com. For more information about sending authorization,
144	// see the Amazon SES Developer Guide
145	// (https://docs.aws.amazon.com/ses/latest/DeveloperGuide/sending-authorization.html).
146	SourceArn *string
147
148	// A list of tags, in the form of name/value pairs, to apply to an email that you
149	// send using SendEmail. Tags correspond to characteristics of the email that you
150	// define, so that you can publish email sending events.
151	Tags []types.MessageTag
152}
153
154// Represents a unique message ID.
155type SendEmailOutput struct {
156
157	// The unique message identifier returned from the SendEmail action.
158	//
159	// This member is required.
160	MessageId *string
161
162	// Metadata pertaining to the operation's result.
163	ResultMetadata middleware.Metadata
164}
165
166func addOperationSendEmailMiddlewares(stack *middleware.Stack, options Options) (err error) {
167	err = stack.Serialize.Add(&awsAwsquery_serializeOpSendEmail{}, middleware.After)
168	if err != nil {
169		return err
170	}
171	err = stack.Deserialize.Add(&awsAwsquery_deserializeOpSendEmail{}, middleware.After)
172	if err != nil {
173		return err
174	}
175	if err = addSetLoggerMiddleware(stack, options); err != nil {
176		return err
177	}
178	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
179		return err
180	}
181	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
182		return err
183	}
184	if err = addResolveEndpointMiddleware(stack, options); err != nil {
185		return err
186	}
187	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
188		return err
189	}
190	if err = addRetryMiddlewares(stack, options); err != nil {
191		return err
192	}
193	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
194		return err
195	}
196	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
197		return err
198	}
199	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
200		return err
201	}
202	if err = addClientUserAgent(stack); err != nil {
203		return err
204	}
205	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
206		return err
207	}
208	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
209		return err
210	}
211	if err = addOpSendEmailValidationMiddleware(stack); err != nil {
212		return err
213	}
214	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opSendEmail(options.Region), middleware.Before); err != nil {
215		return err
216	}
217	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
218		return err
219	}
220	if err = addResponseErrorMiddleware(stack); err != nil {
221		return err
222	}
223	if err = addRequestResponseLogging(stack, options); err != nil {
224		return err
225	}
226	return nil
227}
228
229func newServiceMetadataMiddleware_opSendEmail(region string) *awsmiddleware.RegisterServiceMetadata {
230	return &awsmiddleware.RegisterServiceMetadata{
231		Region:        region,
232		ServiceID:     ServiceID,
233		SigningName:   "ses",
234		OperationName: "SendEmail",
235	}
236}
237