1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package pinpointemail
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/pinpointemail/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 Pinpoint Email API to send two
15// types of messages:
16//
17// * Simple – A standard email message. When you create this
18// type of message, you specify the sender, the recipient, and the message body,
19// and Amazon Pinpoint assembles the message for you.
20//
21// * Raw – A raw,
22// MIME-formatted email message. When you send this type of email, you have to
23// specify all of the message headers, as well as the message body. You can use
24// this message type to send messages that contain attachments. The message that
25// you specify has to be a valid MIME message.
26func (c *Client) SendEmail(ctx context.Context, params *SendEmailInput, optFns ...func(*Options)) (*SendEmailOutput, error) {
27	if params == nil {
28		params = &SendEmailInput{}
29	}
30
31	result, metadata, err := c.invokeOperation(ctx, "SendEmail", params, optFns, addOperationSendEmailMiddlewares)
32	if err != nil {
33		return nil, err
34	}
35
36	out := result.(*SendEmailOutput)
37	out.ResultMetadata = metadata
38	return out, nil
39}
40
41// A request to send an email message.
42type SendEmailInput struct {
43
44	// An object that contains the body of the message. You can send either a Simple
45	// message or a Raw message.
46	//
47	// This member is required.
48	Content *types.EmailContent
49
50	// An object that contains the recipients of the email message.
51	//
52	// This member is required.
53	Destination *types.Destination
54
55	// The name of the configuration set that you want to use when sending the email.
56	ConfigurationSetName *string
57
58	// A list of tags, in the form of name/value pairs, to apply to an email that you
59	// send using the SendEmail operation. Tags correspond to characteristics of the
60	// email that you define, so that you can publish email sending events.
61	EmailTags []types.MessageTag
62
63	// The address that Amazon Pinpoint should send bounce and complaint notifications
64	// to.
65	FeedbackForwardingEmailAddress *string
66
67	// The email address that you want to use as the "From" address for the email. The
68	// address that you specify has to be verified.
69	FromEmailAddress *string
70
71	// The "Reply-to" email addresses for the message. When the recipient replies to
72	// the message, each Reply-to address receives the reply.
73	ReplyToAddresses []string
74}
75
76// A unique message ID that you receive when Amazon Pinpoint accepts an email for
77// sending.
78type SendEmailOutput struct {
79
80	// A unique identifier for the message that is generated when Amazon Pinpoint
81	// accepts the message. It is possible for Amazon Pinpoint to accept a message
82	// without sending it. This can happen when the message you're trying to send has
83	// an attachment doesn't pass a virus check, or when you send a templated email
84	// that contains invalid personalization content, for example.
85	MessageId *string
86
87	// Metadata pertaining to the operation's result.
88	ResultMetadata middleware.Metadata
89}
90
91func addOperationSendEmailMiddlewares(stack *middleware.Stack, options Options) (err error) {
92	err = stack.Serialize.Add(&awsRestjson1_serializeOpSendEmail{}, middleware.After)
93	if err != nil {
94		return err
95	}
96	err = stack.Deserialize.Add(&awsRestjson1_deserializeOpSendEmail{}, middleware.After)
97	if err != nil {
98		return err
99	}
100	if err = addSetLoggerMiddleware(stack, options); err != nil {
101		return err
102	}
103	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
104		return err
105	}
106	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
107		return err
108	}
109	if err = addResolveEndpointMiddleware(stack, options); err != nil {
110		return err
111	}
112	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
113		return err
114	}
115	if err = addRetryMiddlewares(stack, options); err != nil {
116		return err
117	}
118	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
119		return err
120	}
121	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
122		return err
123	}
124	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
125		return err
126	}
127	if err = addClientUserAgent(stack); err != nil {
128		return err
129	}
130	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
131		return err
132	}
133	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
134		return err
135	}
136	if err = addOpSendEmailValidationMiddleware(stack); err != nil {
137		return err
138	}
139	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opSendEmail(options.Region), middleware.Before); err != nil {
140		return err
141	}
142	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
143		return err
144	}
145	if err = addResponseErrorMiddleware(stack); err != nil {
146		return err
147	}
148	if err = addRequestResponseLogging(stack, options); err != nil {
149		return err
150	}
151	return nil
152}
153
154func newServiceMetadataMiddleware_opSendEmail(region string) *awsmiddleware.RegisterServiceMetadata {
155	return &awsmiddleware.RegisterServiceMetadata{
156		Region:        region,
157		ServiceID:     ServiceID,
158		SigningName:   "ses",
159		OperationName: "SendEmail",
160	}
161}
162