1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package sesv2
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/sesv2/types"
10	"github.com/aws/smithy-go/middleware"
11	smithyhttp "github.com/aws/smithy-go/transport/http"
12)
13
14// Sends an email message. You can use the Amazon SES API v2 to send two types of
15// messages:
16//
17// * Simple – A standard email message. When you create this type of
18// message, you specify the sender, the recipient, and the message body, and Amazon
19// SES assembles the message for you.
20//
21// * Raw – A raw, MIME-formatted email message.
22// When you send this type of email, you have to specify all of the message
23// headers, as well as the message body. You can use this message type to send
24// messages that contain attachments. The message that you specify has to be a
25// valid MIME message.
26//
27// * Templated – A message that contains personalization tags.
28// When you send this type of email, Amazon SES API v2 automatically replaces the
29// tags with values that you specify.
30func (c *Client) SendEmail(ctx context.Context, params *SendEmailInput, optFns ...func(*Options)) (*SendEmailOutput, error) {
31	if params == nil {
32		params = &SendEmailInput{}
33	}
34
35	result, metadata, err := c.invokeOperation(ctx, "SendEmail", params, optFns, c.addOperationSendEmailMiddlewares)
36	if err != nil {
37		return nil, err
38	}
39
40	out := result.(*SendEmailOutput)
41	out.ResultMetadata = metadata
42	return out, nil
43}
44
45// Represents a request to send a single formatted email using Amazon SES. For more
46// information, see the Amazon SES Developer Guide
47// (https://docs.aws.amazon.com/ses/latest/DeveloperGuide/send-email-formatted.html).
48type SendEmailInput struct {
49
50	// An object that contains the body of the message. You can send either a Simple
51	// message Raw message or a template Message.
52	//
53	// This member is required.
54	Content *types.EmailContent
55
56	// The name of the configuration set that you want to use when sending the email.
57	ConfigurationSetName *string
58
59	// An object that contains the recipients of the email message.
60	Destination *types.Destination
61
62	// A list of tags, in the form of name/value pairs, to apply to an email that you
63	// send using the SendEmail operation. Tags correspond to characteristics of the
64	// email that you define, so that you can publish email sending events.
65	EmailTags []types.MessageTag
66
67	// The address that you want bounce and complaint notifications to be sent to.
68	FeedbackForwardingEmailAddress *string
69
70	// This parameter is used only for sending authorization. It is the ARN of the
71	// identity that is associated with the sending authorization policy that permits
72	// you to use the email address specified in the FeedbackForwardingEmailAddress
73	// parameter. For example, if the owner of example.com (which has ARN
74	// arn:aws:ses:us-east-1:123456789012:identity/example.com) attaches a policy to it
75	// that authorizes you to use feedback@example.com, then you would specify the
76	// FeedbackForwardingEmailAddressIdentityArn to be
77	// arn:aws:ses:us-east-1:123456789012:identity/example.com, and the
78	// FeedbackForwardingEmailAddress to be feedback@example.com. For more information
79	// about sending authorization, see the Amazon SES Developer Guide
80	// (https://docs.aws.amazon.com/ses/latest/DeveloperGuide/sending-authorization.html).
81	FeedbackForwardingEmailAddressIdentityArn *string
82
83	// The email address that you want to use as the "From" address for the email. The
84	// address that you specify has to be verified.
85	FromEmailAddress *string
86
87	// This parameter is used only for sending authorization. It is the ARN of the
88	// identity that is associated with the sending authorization policy that permits
89	// you to use the email address specified in the FromEmailAddress parameter. For
90	// example, if the owner of example.com (which has ARN
91	// arn:aws:ses:us-east-1:123456789012:identity/example.com) attaches a policy to it
92	// that authorizes you to use sender@example.com, then you would specify the
93	// FromEmailAddressIdentityArn to be
94	// arn:aws:ses:us-east-1:123456789012:identity/example.com, and the
95	// FromEmailAddress to be sender@example.com. For more information about sending
96	// authorization, see the Amazon SES Developer Guide
97	// (https://docs.aws.amazon.com/ses/latest/DeveloperGuide/sending-authorization.html).
98	// For Raw emails, the FromEmailAddressIdentityArn value overrides the
99	// X-SES-SOURCE-ARN and X-SES-FROM-ARN headers specified in raw email message
100	// content.
101	FromEmailAddressIdentityArn *string
102
103	// An object used to specify a list or topic to which an email belongs, which will
104	// be used when a contact chooses to unsubscribe.
105	ListManagementOptions *types.ListManagementOptions
106
107	// The "Reply-to" email addresses for the message. When the recipient replies to
108	// the message, each Reply-to address receives the reply.
109	ReplyToAddresses []string
110
111	noSmithyDocumentSerde
112}
113
114// A unique message ID that you receive when an email is accepted for sending.
115type SendEmailOutput struct {
116
117	// A unique identifier for the message that is generated when the message is
118	// accepted. It's possible for Amazon SES to accept a message without sending it.
119	// This can happen when the message that you're trying to send has an attachment
120	// contains a virus, or when you send a templated email that contains invalid
121	// personalization content, for example.
122	MessageId *string
123
124	// Metadata pertaining to the operation's result.
125	ResultMetadata middleware.Metadata
126
127	noSmithyDocumentSerde
128}
129
130func (c *Client) addOperationSendEmailMiddlewares(stack *middleware.Stack, options Options) (err error) {
131	err = stack.Serialize.Add(&awsRestjson1_serializeOpSendEmail{}, middleware.After)
132	if err != nil {
133		return err
134	}
135	err = stack.Deserialize.Add(&awsRestjson1_deserializeOpSendEmail{}, middleware.After)
136	if err != nil {
137		return err
138	}
139	if err = addSetLoggerMiddleware(stack, options); err != nil {
140		return err
141	}
142	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
143		return err
144	}
145	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
146		return err
147	}
148	if err = addResolveEndpointMiddleware(stack, options); err != nil {
149		return err
150	}
151	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
152		return err
153	}
154	if err = addRetryMiddlewares(stack, options); err != nil {
155		return err
156	}
157	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
158		return err
159	}
160	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
161		return err
162	}
163	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
164		return err
165	}
166	if err = addClientUserAgent(stack); err != nil {
167		return err
168	}
169	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
170		return err
171	}
172	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
173		return err
174	}
175	if err = addOpSendEmailValidationMiddleware(stack); err != nil {
176		return err
177	}
178	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opSendEmail(options.Region), middleware.Before); err != nil {
179		return err
180	}
181	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
182		return err
183	}
184	if err = addResponseErrorMiddleware(stack); err != nil {
185		return err
186	}
187	if err = addRequestResponseLogging(stack, options); err != nil {
188		return err
189	}
190	return nil
191}
192
193func newServiceMetadataMiddleware_opSendEmail(region string) *awsmiddleware.RegisterServiceMetadata {
194	return &awsmiddleware.RegisterServiceMetadata{
195		Region:        region,
196		ServiceID:     ServiceID,
197		SigningName:   "ses",
198		OperationName: "SendEmail",
199	}
200}
201