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. This operation 15// is more flexible than the SendEmail API operation. When you use the SendRawEmail 16// operation, you can specify the headers of the message as well as its content. 17// This flexibility is useful, for example, when you want to send a multipart MIME 18// email (such a message that contains both a text and an HTML version). You can 19// also use this operation to send messages that include attachments. The 20// SendRawEmail operation has the following requirements: 21// 22// * You can only send 23// email from verified email addresses or domains 24// (https://docs.aws.amazon.com/ses/latest/DeveloperGuide/verify-addresses-and-domains.html). 25// If you try to send email from an address that isn't verified, the operation 26// results in an "Email address not verified" error. 27// 28// * If your account is still in 29// the Amazon SES sandbox 30// (https://docs.aws.amazon.com/ses/latest/DeveloperGuide/request-production-access.html), 31// you can only send email to other verified addresses in your account, or to 32// addresses that are associated with the Amazon SES mailbox simulator 33// (https://docs.aws.amazon.com/ses/latest/DeveloperGuide/mailbox-simulator.html). 34// 35// * 36// The maximum message size, including attachments, is 10 MB. 37// 38// * Each message has 39// to include at least one recipient address. A recipient address includes any 40// address on the To:, CC:, or BCC: lines. 41// 42// * If you send a single message to more 43// than one recipient address, and one of the recipient addresses isn't in a valid 44// format (that is, it's not in the format 45// UserName@[SubDomain.]Domain.TopLevelDomain), Amazon SES rejects the entire 46// message, even if the other addresses are valid. 47// 48// * Each message can include up 49// to 50 recipient addresses across the To:, CC:, or BCC: lines. If you need to 50// send a single message to more than 50 recipients, you have to split the list of 51// recipient addresses into groups of less than 50 recipients, and send separate 52// messages to each group. 53// 54// * Amazon SES allows you to specify 8-bit 55// Content-Transfer-Encoding for MIME message parts. However, if Amazon SES has to 56// modify the contents of your message (for example, if you use open and click 57// tracking), 8-bit content isn't preserved. For this reason, we highly recommend 58// that you encode all content that isn't 7-bit ASCII. For more information, see 59// MIME Encoding 60// (https://docs.aws.amazon.com/ses/latest/DeveloperGuide/send-email-raw.html#send-email-mime-encoding) 61// in the Amazon SES Developer Guide. 62// 63// Additionally, keep the following 64// considerations in mind when using the SendRawEmail operation: 65// 66// * Although you 67// can customize the message headers when using the SendRawEmail operation, Amazon 68// SES will automatically apply its own Message-ID and Date headers; if you passed 69// these headers when creating the message, they will be overwritten by the values 70// that Amazon SES provides. 71// 72// * If you are using sending authorization to send on 73// behalf of another user, SendRawEmail enables you to specify the cross-account 74// identity for the email's Source, From, and Return-Path parameters in one of two 75// ways: you can pass optional parameters SourceArn, FromArn, and/or ReturnPathArn 76// to the API, or you can include the following X-headers in the header of your raw 77// email: 78// 79// * X-SES-SOURCE-ARN 80// 81// * X-SES-FROM-ARN 82// 83// * X-SES-RETURN-PATH-ARN 84// 85// Don't 86// include these X-headers in the DKIM signature. Amazon SES removes these before 87// it sends the email. If you only specify the SourceIdentityArn parameter, Amazon 88// SES sets the From and Return-Path addresses to the same identity that you 89// specified. For more information about sending authorization, see the Using 90// Sending Authorization with Amazon SES 91// (https://docs.aws.amazon.com/ses/latest/DeveloperGuide/sending-authorization.html) 92// in the Amazon SES Developer Guide. 93// 94// * For every message that you send, the total 95// number of recipients (including each recipient in the To:, CC: and BCC: fields) 96// is counted against the maximum number of emails you can send in a 24-hour period 97// (your sending quota). For more information about sending quotas in Amazon SES, 98// see Managing Your Amazon SES Sending Limits 99// (https://docs.aws.amazon.com/ses/latest/DeveloperGuide/manage-sending-limits.html) 100// in the Amazon SES Developer Guide. 101func (c *Client) SendRawEmail(ctx context.Context, params *SendRawEmailInput, optFns ...func(*Options)) (*SendRawEmailOutput, error) { 102 if params == nil { 103 params = &SendRawEmailInput{} 104 } 105 106 result, metadata, err := c.invokeOperation(ctx, "SendRawEmail", params, optFns, addOperationSendRawEmailMiddlewares) 107 if err != nil { 108 return nil, err 109 } 110 111 out := result.(*SendRawEmailOutput) 112 out.ResultMetadata = metadata 113 return out, nil 114} 115 116// Represents a request to send a single raw email using Amazon SES. For more 117// information, see the Amazon SES Developer Guide 118// (https://docs.aws.amazon.com/ses/latest/DeveloperGuide/send-email-raw.html). 119type SendRawEmailInput struct { 120 121 // The raw email message itself. The message has to meet the following criteria: 122 // 123 // * 124 // The message has to contain a header and a body, separated by a blank line. 125 // 126 // * 127 // All of the required header fields must be present in the message. 128 // 129 // * Each part 130 // of a multipart MIME message must be formatted properly. 131 // 132 // * Attachments must be 133 // of a content type that Amazon SES supports. For a list on unsupported content 134 // types, see Unsupported Attachment Types 135 // (https://docs.aws.amazon.com/ses/latest/DeveloperGuide/mime-types.html) in the 136 // Amazon SES Developer Guide. 137 // 138 // * The entire message must be base64-encoded. 139 // 140 // * If 141 // any of the MIME parts in your message contain content that is outside of the 142 // 7-bit ASCII character range, we highly recommend that you encode that content. 143 // For more information, see Sending Raw Email 144 // (https://docs.aws.amazon.com/ses/latest/DeveloperGuide/send-email-raw.html) in 145 // the Amazon SES Developer Guide. 146 // 147 // * Per RFC 5321 148 // (https://tools.ietf.org/html/rfc5321#section-4.5.3.1.6), the maximum length of 149 // each line of text, including the , must not exceed 1,000 characters. 150 // 151 // This member is required. 152 RawMessage *types.RawMessage 153 154 // The name of the configuration set to use when you send an email using 155 // SendRawEmail. 156 ConfigurationSetName *string 157 158 // A list of destinations for the message, consisting of To:, CC:, and BCC: 159 // addresses. 160 Destinations []string 161 162 // This parameter is used only for sending authorization. It is the ARN of the 163 // identity that is associated with the sending authorization policy that permits 164 // you to specify a particular "From" address in the header of the raw email. 165 // Instead of using this parameter, you can use the X-header X-SES-FROM-ARN in the 166 // raw message of the email. If you use both the FromArn parameter and the 167 // corresponding X-header, Amazon SES uses the value of the FromArn parameter. For 168 // information about when to use this parameter, see the description of 169 // SendRawEmail in this guide, or see the Amazon SES Developer Guide 170 // (https://docs.aws.amazon.com/ses/latest/DeveloperGuide/sending-authorization-delegate-sender-tasks-email.html). 171 FromArn *string 172 173 // This parameter is used only for sending authorization. It is the ARN of the 174 // identity that is associated with the sending authorization policy that permits 175 // you to use the email address specified in the ReturnPath parameter. For example, 176 // if the owner of example.com (which has ARN 177 // arn:aws:ses:us-east-1:123456789012:identity/example.com) attaches a policy to it 178 // that authorizes you to use feedback@example.com, then you would specify the 179 // ReturnPathArn to be arn:aws:ses:us-east-1:123456789012:identity/example.com, and 180 // the ReturnPath to be feedback@example.com. Instead of using this parameter, you 181 // can use the X-header X-SES-RETURN-PATH-ARN in the raw message of the email. If 182 // you use both the ReturnPathArn parameter and the corresponding X-header, Amazon 183 // SES uses the value of the ReturnPathArn parameter. For information about when to 184 // use this parameter, see the description of SendRawEmail in this guide, or see 185 // the Amazon SES Developer Guide 186 // (https://docs.aws.amazon.com/ses/latest/DeveloperGuide/sending-authorization-delegate-sender-tasks-email.html). 187 ReturnPathArn *string 188 189 // The identity's email address. If you do not provide a value for this parameter, 190 // you must specify a "From" address in the raw text of the message. (You can also 191 // specify both.) Amazon SES does not support the SMTPUTF8 extension, as described 192 // inRFC6531 (https://tools.ietf.org/html/rfc6531). For this reason, the local part 193 // of a source email address (the part of the email address that precedes the @ 194 // sign) may only contain 7-bit ASCII characters 195 // (https://en.wikipedia.org/wiki/Email_address#Local-part). If the domain part of 196 // an address (the part after the @ sign) contains non-ASCII characters, they must 197 // be encoded using Punycode, as described in RFC3492 198 // (https://tools.ietf.org/html/rfc3492.html). The sender name (also known as the 199 // friendly name) may contain non-ASCII characters. These characters must be 200 // encoded using MIME encoded-word syntax, as described in RFC 2047 201 // (https://tools.ietf.org/html/rfc2047). MIME encoded-word syntax uses the 202 // following form: =?charset?encoding?encoded-text?=. If you specify the Source 203 // parameter and have feedback forwarding enabled, then bounces and complaints will 204 // be sent to this email address. This takes precedence over any Return-Path header 205 // that you might include in the raw text of the message. 206 Source *string 207 208 // This parameter is used only for sending authorization. It is the ARN of the 209 // identity that is associated with the sending authorization policy that permits 210 // you to send for the email address specified in the Source parameter. For 211 // example, if the owner of example.com (which has ARN 212 // arn:aws:ses:us-east-1:123456789012:identity/example.com) attaches a policy to it 213 // that authorizes you to send from user@example.com, then you would specify the 214 // SourceArn to be arn:aws:ses:us-east-1:123456789012:identity/example.com, and the 215 // Source to be user@example.com. Instead of using this parameter, you can use the 216 // X-header X-SES-SOURCE-ARN in the raw message of the email. If you use both the 217 // SourceArn parameter and the corresponding X-header, Amazon SES uses the value of 218 // the SourceArn parameter. For information about when to use this parameter, see 219 // the description of SendRawEmail in this guide, or see the Amazon SES Developer 220 // Guide 221 // (https://docs.aws.amazon.com/ses/latest/DeveloperGuide/sending-authorization-delegate-sender-tasks-email.html). 222 SourceArn *string 223 224 // A list of tags, in the form of name/value pairs, to apply to an email that you 225 // send using SendRawEmail. Tags correspond to characteristics of the email that 226 // you define, so that you can publish email sending events. 227 Tags []types.MessageTag 228} 229 230// Represents a unique message ID. 231type SendRawEmailOutput struct { 232 233 // The unique message identifier returned from the SendRawEmail action. 234 // 235 // This member is required. 236 MessageId *string 237 238 // Metadata pertaining to the operation's result. 239 ResultMetadata middleware.Metadata 240} 241 242func addOperationSendRawEmailMiddlewares(stack *middleware.Stack, options Options) (err error) { 243 err = stack.Serialize.Add(&awsAwsquery_serializeOpSendRawEmail{}, middleware.After) 244 if err != nil { 245 return err 246 } 247 err = stack.Deserialize.Add(&awsAwsquery_deserializeOpSendRawEmail{}, middleware.After) 248 if err != nil { 249 return err 250 } 251 if err = addSetLoggerMiddleware(stack, options); err != nil { 252 return err 253 } 254 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 255 return err 256 } 257 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 258 return err 259 } 260 if err = addResolveEndpointMiddleware(stack, options); err != nil { 261 return err 262 } 263 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 264 return err 265 } 266 if err = addRetryMiddlewares(stack, options); err != nil { 267 return err 268 } 269 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 270 return err 271 } 272 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 273 return err 274 } 275 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 276 return err 277 } 278 if err = addClientUserAgent(stack); err != nil { 279 return err 280 } 281 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 282 return err 283 } 284 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 285 return err 286 } 287 if err = addOpSendRawEmailValidationMiddleware(stack); err != nil { 288 return err 289 } 290 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opSendRawEmail(options.Region), middleware.Before); err != nil { 291 return err 292 } 293 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 294 return err 295 } 296 if err = addResponseErrorMiddleware(stack); err != nil { 297 return err 298 } 299 if err = addRequestResponseLogging(stack, options); err != nil { 300 return err 301 } 302 return nil 303} 304 305func newServiceMetadataMiddleware_opSendRawEmail(region string) *awsmiddleware.RegisterServiceMetadata { 306 return &awsmiddleware.RegisterServiceMetadata{ 307 Region: region, 308 ServiceID: ServiceID, 309 SigningName: "ses", 310 OperationName: "SendRawEmail", 311 } 312} 313