1// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
2
3package ses_test
4
5import (
6	"fmt"
7	"strings"
8	"time"
9
10	"github.com/aws/aws-sdk-go/aws"
11	"github.com/aws/aws-sdk-go/aws/awserr"
12	"github.com/aws/aws-sdk-go/aws/session"
13	"github.com/aws/aws-sdk-go/service/ses"
14)
15
16var _ time.Duration
17var _ strings.Reader
18var _ aws.Config
19
20func parseTime(layout, value string) *time.Time {
21	t, err := time.Parse(layout, value)
22	if err != nil {
23		panic(err)
24	}
25	return &t
26}
27
28// CloneReceiptRuleSet
29//
30// The following example creates a receipt rule set by cloning an existing one:
31func ExampleSES_CloneReceiptRuleSet_shared00() {
32	svc := ses.New(session.New())
33	input := &ses.CloneReceiptRuleSetInput{
34		OriginalRuleSetName: aws.String("RuleSetToClone"),
35		RuleSetName:         aws.String("RuleSetToCreate"),
36	}
37
38	result, err := svc.CloneReceiptRuleSet(input)
39	if err != nil {
40		if aerr, ok := err.(awserr.Error); ok {
41			switch aerr.Code() {
42			case ses.ErrCodeRuleSetDoesNotExistException:
43				fmt.Println(ses.ErrCodeRuleSetDoesNotExistException, aerr.Error())
44			case ses.ErrCodeAlreadyExistsException:
45				fmt.Println(ses.ErrCodeAlreadyExistsException, aerr.Error())
46			case ses.ErrCodeLimitExceededException:
47				fmt.Println(ses.ErrCodeLimitExceededException, aerr.Error())
48			default:
49				fmt.Println(aerr.Error())
50			}
51		} else {
52			// Print the error, cast err to awserr.Error to get the Code and
53			// Message from an error.
54			fmt.Println(err.Error())
55		}
56		return
57	}
58
59	fmt.Println(result)
60}
61
62// CreateReceiptFilter
63//
64// The following example creates a new IP address filter:
65func ExampleSES_CreateReceiptFilter_shared00() {
66	svc := ses.New(session.New())
67	input := &ses.CreateReceiptFilterInput{
68		Filter: &ses.ReceiptFilter{
69			IpFilter: &ses.ReceiptIpFilter{
70				Cidr:   aws.String("1.2.3.4/24"),
71				Policy: aws.String("Allow"),
72			},
73			Name: aws.String("MyFilter"),
74		},
75	}
76
77	result, err := svc.CreateReceiptFilter(input)
78	if err != nil {
79		if aerr, ok := err.(awserr.Error); ok {
80			switch aerr.Code() {
81			case ses.ErrCodeLimitExceededException:
82				fmt.Println(ses.ErrCodeLimitExceededException, aerr.Error())
83			case ses.ErrCodeAlreadyExistsException:
84				fmt.Println(ses.ErrCodeAlreadyExistsException, aerr.Error())
85			default:
86				fmt.Println(aerr.Error())
87			}
88		} else {
89			// Print the error, cast err to awserr.Error to get the Code and
90			// Message from an error.
91			fmt.Println(err.Error())
92		}
93		return
94	}
95
96	fmt.Println(result)
97}
98
99// CreateReceiptRule
100//
101// The following example creates a new receipt rule:
102func ExampleSES_CreateReceiptRule_shared00() {
103	svc := ses.New(session.New())
104	input := &ses.CreateReceiptRuleInput{
105		After: aws.String(""),
106		Rule: &ses.ReceiptRule{
107			Actions: []*ses.ReceiptAction{
108				{},
109			},
110			Enabled:     aws.Bool(true),
111			Name:        aws.String("MyRule"),
112			ScanEnabled: aws.Bool(true),
113			TlsPolicy:   aws.String("Optional"),
114		},
115		RuleSetName: aws.String("MyRuleSet"),
116	}
117
118	result, err := svc.CreateReceiptRule(input)
119	if err != nil {
120		if aerr, ok := err.(awserr.Error); ok {
121			switch aerr.Code() {
122			case ses.ErrCodeInvalidSnsTopicException:
123				fmt.Println(ses.ErrCodeInvalidSnsTopicException, aerr.Error())
124			case ses.ErrCodeInvalidS3ConfigurationException:
125				fmt.Println(ses.ErrCodeInvalidS3ConfigurationException, aerr.Error())
126			case ses.ErrCodeInvalidLambdaFunctionException:
127				fmt.Println(ses.ErrCodeInvalidLambdaFunctionException, aerr.Error())
128			case ses.ErrCodeAlreadyExistsException:
129				fmt.Println(ses.ErrCodeAlreadyExistsException, aerr.Error())
130			case ses.ErrCodeRuleDoesNotExistException:
131				fmt.Println(ses.ErrCodeRuleDoesNotExistException, aerr.Error())
132			case ses.ErrCodeRuleSetDoesNotExistException:
133				fmt.Println(ses.ErrCodeRuleSetDoesNotExistException, aerr.Error())
134			case ses.ErrCodeLimitExceededException:
135				fmt.Println(ses.ErrCodeLimitExceededException, aerr.Error())
136			default:
137				fmt.Println(aerr.Error())
138			}
139		} else {
140			// Print the error, cast err to awserr.Error to get the Code and
141			// Message from an error.
142			fmt.Println(err.Error())
143		}
144		return
145	}
146
147	fmt.Println(result)
148}
149
150// CreateReceiptRuleSet
151//
152// The following example creates an empty receipt rule set:
153func ExampleSES_CreateReceiptRuleSet_shared00() {
154	svc := ses.New(session.New())
155	input := &ses.CreateReceiptRuleSetInput{
156		RuleSetName: aws.String("MyRuleSet"),
157	}
158
159	result, err := svc.CreateReceiptRuleSet(input)
160	if err != nil {
161		if aerr, ok := err.(awserr.Error); ok {
162			switch aerr.Code() {
163			case ses.ErrCodeAlreadyExistsException:
164				fmt.Println(ses.ErrCodeAlreadyExistsException, aerr.Error())
165			case ses.ErrCodeLimitExceededException:
166				fmt.Println(ses.ErrCodeLimitExceededException, aerr.Error())
167			default:
168				fmt.Println(aerr.Error())
169			}
170		} else {
171			// Print the error, cast err to awserr.Error to get the Code and
172			// Message from an error.
173			fmt.Println(err.Error())
174		}
175		return
176	}
177
178	fmt.Println(result)
179}
180
181// DeleteIdentity
182//
183// The following example deletes an identity from the list of identities that have been
184// submitted for verification with Amazon SES:
185func ExampleSES_DeleteIdentity_shared00() {
186	svc := ses.New(session.New())
187	input := &ses.DeleteIdentityInput{
188		Identity: aws.String("user@example.com"),
189	}
190
191	result, err := svc.DeleteIdentity(input)
192	if err != nil {
193		if aerr, ok := err.(awserr.Error); ok {
194			switch aerr.Code() {
195			default:
196				fmt.Println(aerr.Error())
197			}
198		} else {
199			// Print the error, cast err to awserr.Error to get the Code and
200			// Message from an error.
201			fmt.Println(err.Error())
202		}
203		return
204	}
205
206	fmt.Println(result)
207}
208
209// DeleteIdentityPolicy
210//
211// The following example deletes a sending authorization policy for an identity:
212func ExampleSES_DeleteIdentityPolicy_shared00() {
213	svc := ses.New(session.New())
214	input := &ses.DeleteIdentityPolicyInput{
215		Identity:   aws.String("user@example.com"),
216		PolicyName: aws.String("MyPolicy"),
217	}
218
219	result, err := svc.DeleteIdentityPolicy(input)
220	if err != nil {
221		if aerr, ok := err.(awserr.Error); ok {
222			switch aerr.Code() {
223			default:
224				fmt.Println(aerr.Error())
225			}
226		} else {
227			// Print the error, cast err to awserr.Error to get the Code and
228			// Message from an error.
229			fmt.Println(err.Error())
230		}
231		return
232	}
233
234	fmt.Println(result)
235}
236
237// DeleteReceiptFilter
238//
239// The following example deletes an IP address filter:
240func ExampleSES_DeleteReceiptFilter_shared00() {
241	svc := ses.New(session.New())
242	input := &ses.DeleteReceiptFilterInput{
243		FilterName: aws.String("MyFilter"),
244	}
245
246	result, err := svc.DeleteReceiptFilter(input)
247	if err != nil {
248		if aerr, ok := err.(awserr.Error); ok {
249			switch aerr.Code() {
250			default:
251				fmt.Println(aerr.Error())
252			}
253		} else {
254			// Print the error, cast err to awserr.Error to get the Code and
255			// Message from an error.
256			fmt.Println(err.Error())
257		}
258		return
259	}
260
261	fmt.Println(result)
262}
263
264// DeleteReceiptRule
265//
266// The following example deletes a receipt rule:
267func ExampleSES_DeleteReceiptRule_shared00() {
268	svc := ses.New(session.New())
269	input := &ses.DeleteReceiptRuleInput{
270		RuleName:    aws.String("MyRule"),
271		RuleSetName: aws.String("MyRuleSet"),
272	}
273
274	result, err := svc.DeleteReceiptRule(input)
275	if err != nil {
276		if aerr, ok := err.(awserr.Error); ok {
277			switch aerr.Code() {
278			case ses.ErrCodeRuleSetDoesNotExistException:
279				fmt.Println(ses.ErrCodeRuleSetDoesNotExistException, aerr.Error())
280			default:
281				fmt.Println(aerr.Error())
282			}
283		} else {
284			// Print the error, cast err to awserr.Error to get the Code and
285			// Message from an error.
286			fmt.Println(err.Error())
287		}
288		return
289	}
290
291	fmt.Println(result)
292}
293
294// DeleteReceiptRuleSet
295//
296// The following example deletes a receipt rule set:
297func ExampleSES_DeleteReceiptRuleSet_shared00() {
298	svc := ses.New(session.New())
299	input := &ses.DeleteReceiptRuleSetInput{
300		RuleSetName: aws.String("MyRuleSet"),
301	}
302
303	result, err := svc.DeleteReceiptRuleSet(input)
304	if err != nil {
305		if aerr, ok := err.(awserr.Error); ok {
306			switch aerr.Code() {
307			case ses.ErrCodeCannotDeleteException:
308				fmt.Println(ses.ErrCodeCannotDeleteException, aerr.Error())
309			default:
310				fmt.Println(aerr.Error())
311			}
312		} else {
313			// Print the error, cast err to awserr.Error to get the Code and
314			// Message from an error.
315			fmt.Println(err.Error())
316		}
317		return
318	}
319
320	fmt.Println(result)
321}
322
323// DeleteVerifiedEmailAddress
324//
325// The following example deletes an email address from the list of identities that have
326// been submitted for verification with Amazon SES:
327func ExampleSES_DeleteVerifiedEmailAddress_shared00() {
328	svc := ses.New(session.New())
329	input := &ses.DeleteVerifiedEmailAddressInput{
330		EmailAddress: aws.String("user@example.com"),
331	}
332
333	result, err := svc.DeleteVerifiedEmailAddress(input)
334	if err != nil {
335		if aerr, ok := err.(awserr.Error); ok {
336			switch aerr.Code() {
337			default:
338				fmt.Println(aerr.Error())
339			}
340		} else {
341			// Print the error, cast err to awserr.Error to get the Code and
342			// Message from an error.
343			fmt.Println(err.Error())
344		}
345		return
346	}
347
348	fmt.Println(result)
349}
350
351// DescribeActiveReceiptRuleSet
352//
353// The following example returns the metadata and receipt rules for the receipt rule
354// set that is currently active:
355func ExampleSES_DescribeActiveReceiptRuleSet_shared00() {
356	svc := ses.New(session.New())
357	input := &ses.DescribeActiveReceiptRuleSetInput{}
358
359	result, err := svc.DescribeActiveReceiptRuleSet(input)
360	if err != nil {
361		if aerr, ok := err.(awserr.Error); ok {
362			switch aerr.Code() {
363			default:
364				fmt.Println(aerr.Error())
365			}
366		} else {
367			// Print the error, cast err to awserr.Error to get the Code and
368			// Message from an error.
369			fmt.Println(err.Error())
370		}
371		return
372	}
373
374	fmt.Println(result)
375}
376
377// DescribeReceiptRule
378//
379// The following example returns the details of a receipt rule:
380func ExampleSES_DescribeReceiptRule_shared00() {
381	svc := ses.New(session.New())
382	input := &ses.DescribeReceiptRuleInput{
383		RuleName:    aws.String("MyRule"),
384		RuleSetName: aws.String("MyRuleSet"),
385	}
386
387	result, err := svc.DescribeReceiptRule(input)
388	if err != nil {
389		if aerr, ok := err.(awserr.Error); ok {
390			switch aerr.Code() {
391			case ses.ErrCodeRuleDoesNotExistException:
392				fmt.Println(ses.ErrCodeRuleDoesNotExistException, aerr.Error())
393			case ses.ErrCodeRuleSetDoesNotExistException:
394				fmt.Println(ses.ErrCodeRuleSetDoesNotExistException, aerr.Error())
395			default:
396				fmt.Println(aerr.Error())
397			}
398		} else {
399			// Print the error, cast err to awserr.Error to get the Code and
400			// Message from an error.
401			fmt.Println(err.Error())
402		}
403		return
404	}
405
406	fmt.Println(result)
407}
408
409// DescribeReceiptRuleSet
410//
411// The following example returns the metadata and receipt rules of a receipt rule set:
412func ExampleSES_DescribeReceiptRuleSet_shared00() {
413	svc := ses.New(session.New())
414	input := &ses.DescribeReceiptRuleSetInput{
415		RuleSetName: aws.String("MyRuleSet"),
416	}
417
418	result, err := svc.DescribeReceiptRuleSet(input)
419	if err != nil {
420		if aerr, ok := err.(awserr.Error); ok {
421			switch aerr.Code() {
422			case ses.ErrCodeRuleSetDoesNotExistException:
423				fmt.Println(ses.ErrCodeRuleSetDoesNotExistException, aerr.Error())
424			default:
425				fmt.Println(aerr.Error())
426			}
427		} else {
428			// Print the error, cast err to awserr.Error to get the Code and
429			// Message from an error.
430			fmt.Println(err.Error())
431		}
432		return
433	}
434
435	fmt.Println(result)
436}
437
438// GetIdentityDkimAttributes
439//
440// The following example retrieves the Amazon SES Easy DKIM attributes for a list of
441// identities:
442func ExampleSES_GetIdentityDkimAttributes_shared00() {
443	svc := ses.New(session.New())
444	input := &ses.GetIdentityDkimAttributesInput{
445		Identities: []*string{
446			aws.String("example.com"),
447			aws.String("user@example.com"),
448		},
449	}
450
451	result, err := svc.GetIdentityDkimAttributes(input)
452	if err != nil {
453		if aerr, ok := err.(awserr.Error); ok {
454			switch aerr.Code() {
455			default:
456				fmt.Println(aerr.Error())
457			}
458		} else {
459			// Print the error, cast err to awserr.Error to get the Code and
460			// Message from an error.
461			fmt.Println(err.Error())
462		}
463		return
464	}
465
466	fmt.Println(result)
467}
468
469// GetIdentityMailFromDomainAttributes
470//
471// The following example returns the custom MAIL FROM attributes for an identity:
472func ExampleSES_GetIdentityMailFromDomainAttributes_shared00() {
473	svc := ses.New(session.New())
474	input := &ses.GetIdentityMailFromDomainAttributesInput{
475		Identities: []*string{
476			aws.String("example.com"),
477		},
478	}
479
480	result, err := svc.GetIdentityMailFromDomainAttributes(input)
481	if err != nil {
482		if aerr, ok := err.(awserr.Error); ok {
483			switch aerr.Code() {
484			default:
485				fmt.Println(aerr.Error())
486			}
487		} else {
488			// Print the error, cast err to awserr.Error to get the Code and
489			// Message from an error.
490			fmt.Println(err.Error())
491		}
492		return
493	}
494
495	fmt.Println(result)
496}
497
498// GetIdentityNotificationAttributes
499//
500// The following example returns the notification attributes for an identity:
501func ExampleSES_GetIdentityNotificationAttributes_shared00() {
502	svc := ses.New(session.New())
503	input := &ses.GetIdentityNotificationAttributesInput{
504		Identities: []*string{
505			aws.String("example.com"),
506		},
507	}
508
509	result, err := svc.GetIdentityNotificationAttributes(input)
510	if err != nil {
511		if aerr, ok := err.(awserr.Error); ok {
512			switch aerr.Code() {
513			default:
514				fmt.Println(aerr.Error())
515			}
516		} else {
517			// Print the error, cast err to awserr.Error to get the Code and
518			// Message from an error.
519			fmt.Println(err.Error())
520		}
521		return
522	}
523
524	fmt.Println(result)
525}
526
527// GetIdentityPolicies
528//
529// The following example returns a sending authorization policy for an identity:
530func ExampleSES_GetIdentityPolicies_shared00() {
531	svc := ses.New(session.New())
532	input := &ses.GetIdentityPoliciesInput{
533		Identity: aws.String("example.com"),
534		PolicyNames: []*string{
535			aws.String("MyPolicy"),
536		},
537	}
538
539	result, err := svc.GetIdentityPolicies(input)
540	if err != nil {
541		if aerr, ok := err.(awserr.Error); ok {
542			switch aerr.Code() {
543			default:
544				fmt.Println(aerr.Error())
545			}
546		} else {
547			// Print the error, cast err to awserr.Error to get the Code and
548			// Message from an error.
549			fmt.Println(err.Error())
550		}
551		return
552	}
553
554	fmt.Println(result)
555}
556
557// GetIdentityVerificationAttributes
558//
559// The following example returns the verification status and the verification token
560// for a domain identity:
561func ExampleSES_GetIdentityVerificationAttributes_shared00() {
562	svc := ses.New(session.New())
563	input := &ses.GetIdentityVerificationAttributesInput{
564		Identities: []*string{
565			aws.String("example.com"),
566		},
567	}
568
569	result, err := svc.GetIdentityVerificationAttributes(input)
570	if err != nil {
571		if aerr, ok := err.(awserr.Error); ok {
572			switch aerr.Code() {
573			default:
574				fmt.Println(aerr.Error())
575			}
576		} else {
577			// Print the error, cast err to awserr.Error to get the Code and
578			// Message from an error.
579			fmt.Println(err.Error())
580		}
581		return
582	}
583
584	fmt.Println(result)
585}
586
587// GetSendQuota
588//
589// The following example returns the Amazon SES sending limits for an AWS account:
590func ExampleSES_GetSendQuota_shared00() {
591	svc := ses.New(session.New())
592	input := &ses.GetSendQuotaInput{}
593
594	result, err := svc.GetSendQuota(input)
595	if err != nil {
596		if aerr, ok := err.(awserr.Error); ok {
597			switch aerr.Code() {
598			default:
599				fmt.Println(aerr.Error())
600			}
601		} else {
602			// Print the error, cast err to awserr.Error to get the Code and
603			// Message from an error.
604			fmt.Println(err.Error())
605		}
606		return
607	}
608
609	fmt.Println(result)
610}
611
612// GetSendStatistics
613//
614// The following example returns Amazon SES sending statistics:
615func ExampleSES_GetSendStatistics_shared00() {
616	svc := ses.New(session.New())
617	input := &ses.GetSendStatisticsInput{}
618
619	result, err := svc.GetSendStatistics(input)
620	if err != nil {
621		if aerr, ok := err.(awserr.Error); ok {
622			switch aerr.Code() {
623			default:
624				fmt.Println(aerr.Error())
625			}
626		} else {
627			// Print the error, cast err to awserr.Error to get the Code and
628			// Message from an error.
629			fmt.Println(err.Error())
630		}
631		return
632	}
633
634	fmt.Println(result)
635}
636
637// ListIdentities
638//
639// The following example lists the email address identities that have been submitted
640// for verification with Amazon SES:
641func ExampleSES_ListIdentities_shared00() {
642	svc := ses.New(session.New())
643	input := &ses.ListIdentitiesInput{
644		IdentityType: aws.String("EmailAddress"),
645		MaxItems:     aws.Int64(123),
646		NextToken:    aws.String(""),
647	}
648
649	result, err := svc.ListIdentities(input)
650	if err != nil {
651		if aerr, ok := err.(awserr.Error); ok {
652			switch aerr.Code() {
653			default:
654				fmt.Println(aerr.Error())
655			}
656		} else {
657			// Print the error, cast err to awserr.Error to get the Code and
658			// Message from an error.
659			fmt.Println(err.Error())
660		}
661		return
662	}
663
664	fmt.Println(result)
665}
666
667// ListIdentityPolicies
668//
669// The following example returns a list of sending authorization policies that are attached
670// to an identity:
671func ExampleSES_ListIdentityPolicies_shared00() {
672	svc := ses.New(session.New())
673	input := &ses.ListIdentityPoliciesInput{
674		Identity: aws.String("example.com"),
675	}
676
677	result, err := svc.ListIdentityPolicies(input)
678	if err != nil {
679		if aerr, ok := err.(awserr.Error); ok {
680			switch aerr.Code() {
681			default:
682				fmt.Println(aerr.Error())
683			}
684		} else {
685			// Print the error, cast err to awserr.Error to get the Code and
686			// Message from an error.
687			fmt.Println(err.Error())
688		}
689		return
690	}
691
692	fmt.Println(result)
693}
694
695// ListReceiptFilters
696//
697// The following example lists the IP address filters that are associated with an AWS
698// account:
699func ExampleSES_ListReceiptFilters_shared00() {
700	svc := ses.New(session.New())
701	input := &ses.ListReceiptFiltersInput{}
702
703	result, err := svc.ListReceiptFilters(input)
704	if err != nil {
705		if aerr, ok := err.(awserr.Error); ok {
706			switch aerr.Code() {
707			default:
708				fmt.Println(aerr.Error())
709			}
710		} else {
711			// Print the error, cast err to awserr.Error to get the Code and
712			// Message from an error.
713			fmt.Println(err.Error())
714		}
715		return
716	}
717
718	fmt.Println(result)
719}
720
721// ListReceiptRuleSets
722//
723// The following example lists the receipt rule sets that exist under an AWS account:
724func ExampleSES_ListReceiptRuleSets_shared00() {
725	svc := ses.New(session.New())
726	input := &ses.ListReceiptRuleSetsInput{
727		NextToken: aws.String(""),
728	}
729
730	result, err := svc.ListReceiptRuleSets(input)
731	if err != nil {
732		if aerr, ok := err.(awserr.Error); ok {
733			switch aerr.Code() {
734			default:
735				fmt.Println(aerr.Error())
736			}
737		} else {
738			// Print the error, cast err to awserr.Error to get the Code and
739			// Message from an error.
740			fmt.Println(err.Error())
741		}
742		return
743	}
744
745	fmt.Println(result)
746}
747
748// ListVerifiedEmailAddresses
749//
750// The following example lists all email addresses that have been submitted for verification
751// with Amazon SES:
752func ExampleSES_ListVerifiedEmailAddresses_shared00() {
753	svc := ses.New(session.New())
754	input := &ses.ListVerifiedEmailAddressesInput{}
755
756	result, err := svc.ListVerifiedEmailAddresses(input)
757	if err != nil {
758		if aerr, ok := err.(awserr.Error); ok {
759			switch aerr.Code() {
760			default:
761				fmt.Println(aerr.Error())
762			}
763		} else {
764			// Print the error, cast err to awserr.Error to get the Code and
765			// Message from an error.
766			fmt.Println(err.Error())
767		}
768		return
769	}
770
771	fmt.Println(result)
772}
773
774// PutIdentityPolicy
775//
776// The following example adds a sending authorization policy to an identity:
777func ExampleSES_PutIdentityPolicy_shared00() {
778	svc := ses.New(session.New())
779	input := &ses.PutIdentityPolicyInput{
780		Identity:   aws.String("example.com"),
781		Policy:     aws.String("{\"Version\":\"2008-10-17\",\"Statement\":[{\"Sid\":\"stmt1469123904194\",\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"arn:aws:iam::123456789012:root\"},\"Action\":[\"ses:SendEmail\",\"ses:SendRawEmail\"],\"Resource\":\"arn:aws:ses:us-east-1:EXAMPLE65304:identity/example.com\"}]}"),
782		PolicyName: aws.String("MyPolicy"),
783	}
784
785	result, err := svc.PutIdentityPolicy(input)
786	if err != nil {
787		if aerr, ok := err.(awserr.Error); ok {
788			switch aerr.Code() {
789			case ses.ErrCodeInvalidPolicyException:
790				fmt.Println(ses.ErrCodeInvalidPolicyException, aerr.Error())
791			default:
792				fmt.Println(aerr.Error())
793			}
794		} else {
795			// Print the error, cast err to awserr.Error to get the Code and
796			// Message from an error.
797			fmt.Println(err.Error())
798		}
799		return
800	}
801
802	fmt.Println(result)
803}
804
805// ReorderReceiptRuleSet
806//
807// The following example reorders the receipt rules within a receipt rule set:
808func ExampleSES_ReorderReceiptRuleSet_shared00() {
809	svc := ses.New(session.New())
810	input := &ses.ReorderReceiptRuleSetInput{
811		RuleNames: []*string{
812			aws.String("MyRule"),
813			aws.String("MyOtherRule"),
814		},
815		RuleSetName: aws.String("MyRuleSet"),
816	}
817
818	result, err := svc.ReorderReceiptRuleSet(input)
819	if err != nil {
820		if aerr, ok := err.(awserr.Error); ok {
821			switch aerr.Code() {
822			case ses.ErrCodeRuleSetDoesNotExistException:
823				fmt.Println(ses.ErrCodeRuleSetDoesNotExistException, aerr.Error())
824			case ses.ErrCodeRuleDoesNotExistException:
825				fmt.Println(ses.ErrCodeRuleDoesNotExistException, aerr.Error())
826			default:
827				fmt.Println(aerr.Error())
828			}
829		} else {
830			// Print the error, cast err to awserr.Error to get the Code and
831			// Message from an error.
832			fmt.Println(err.Error())
833		}
834		return
835	}
836
837	fmt.Println(result)
838}
839
840// SendEmail
841//
842// The following example sends a formatted email:
843func ExampleSES_SendEmail_shared00() {
844	svc := ses.New(session.New())
845	input := &ses.SendEmailInput{
846		Destination: &ses.Destination{
847			CcAddresses: []*string{
848				aws.String("recipient3@example.com"),
849			},
850			ToAddresses: []*string{
851				aws.String("recipient1@example.com"),
852				aws.String("recipient2@example.com"),
853			},
854		},
855		Message: &ses.Message{
856			Body: &ses.Body{
857				Html: &ses.Content{
858					Charset: aws.String("UTF-8"),
859					Data:    aws.String("This message body contains HTML formatting. It can, for example, contain links like this one: <a class=\"ulink\" href=\"http://docs.aws.amazon.com/ses/latest/DeveloperGuide\" target=\"_blank\">Amazon SES Developer Guide</a>."),
860				},
861				Text: &ses.Content{
862					Charset: aws.String("UTF-8"),
863					Data:    aws.String("This is the message body in text format."),
864				},
865			},
866			Subject: &ses.Content{
867				Charset: aws.String("UTF-8"),
868				Data:    aws.String("Test email"),
869			},
870		},
871		ReturnPath:    aws.String(""),
872		ReturnPathArn: aws.String(""),
873		Source:        aws.String("sender@example.com"),
874		SourceArn:     aws.String(""),
875	}
876
877	result, err := svc.SendEmail(input)
878	if err != nil {
879		if aerr, ok := err.(awserr.Error); ok {
880			switch aerr.Code() {
881			case ses.ErrCodeMessageRejected:
882				fmt.Println(ses.ErrCodeMessageRejected, aerr.Error())
883			case ses.ErrCodeMailFromDomainNotVerifiedException:
884				fmt.Println(ses.ErrCodeMailFromDomainNotVerifiedException, aerr.Error())
885			case ses.ErrCodeConfigurationSetDoesNotExistException:
886				fmt.Println(ses.ErrCodeConfigurationSetDoesNotExistException, aerr.Error())
887			default:
888				fmt.Println(aerr.Error())
889			}
890		} else {
891			// Print the error, cast err to awserr.Error to get the Code and
892			// Message from an error.
893			fmt.Println(err.Error())
894		}
895		return
896	}
897
898	fmt.Println(result)
899}
900
901// SendRawEmail
902//
903// The following example sends an email with an attachment:
904func ExampleSES_SendRawEmail_shared00() {
905	svc := ses.New(session.New())
906	input := &ses.SendRawEmailInput{
907		FromArn: aws.String(""),
908		RawMessage: &ses.RawMessage{
909			Data: []byte("From: sender@example.com\\nTo: recipient@example.com\\nSubject: Test email (contains an attachment)\\nMIME-Version: 1.0\\nContent-type: Multipart/Mixed; boundary=\"NextPart\"\\n\\n--NextPart\\nContent-Type: text/plain\\n\\nThis is the message body.\\n\\n--NextPart\\nContent-Type: text/plain;\\nContent-Disposition: attachment; filename=\"attachment.txt\"\\n\\nThis is the text in the attachment.\\n\\n--NextPart--"),
910		},
911		ReturnPathArn: aws.String(""),
912		Source:        aws.String(""),
913		SourceArn:     aws.String(""),
914	}
915
916	result, err := svc.SendRawEmail(input)
917	if err != nil {
918		if aerr, ok := err.(awserr.Error); ok {
919			switch aerr.Code() {
920			case ses.ErrCodeMessageRejected:
921				fmt.Println(ses.ErrCodeMessageRejected, aerr.Error())
922			case ses.ErrCodeMailFromDomainNotVerifiedException:
923				fmt.Println(ses.ErrCodeMailFromDomainNotVerifiedException, aerr.Error())
924			case ses.ErrCodeConfigurationSetDoesNotExistException:
925				fmt.Println(ses.ErrCodeConfigurationSetDoesNotExistException, aerr.Error())
926			default:
927				fmt.Println(aerr.Error())
928			}
929		} else {
930			// Print the error, cast err to awserr.Error to get the Code and
931			// Message from an error.
932			fmt.Println(err.Error())
933		}
934		return
935	}
936
937	fmt.Println(result)
938}
939
940// SetActiveReceiptRuleSet
941//
942// The following example sets the active receipt rule set:
943func ExampleSES_SetActiveReceiptRuleSet_shared00() {
944	svc := ses.New(session.New())
945	input := &ses.SetActiveReceiptRuleSetInput{
946		RuleSetName: aws.String("RuleSetToActivate"),
947	}
948
949	result, err := svc.SetActiveReceiptRuleSet(input)
950	if err != nil {
951		if aerr, ok := err.(awserr.Error); ok {
952			switch aerr.Code() {
953			case ses.ErrCodeRuleSetDoesNotExistException:
954				fmt.Println(ses.ErrCodeRuleSetDoesNotExistException, aerr.Error())
955			default:
956				fmt.Println(aerr.Error())
957			}
958		} else {
959			// Print the error, cast err to awserr.Error to get the Code and
960			// Message from an error.
961			fmt.Println(err.Error())
962		}
963		return
964	}
965
966	fmt.Println(result)
967}
968
969// SetIdentityDkimEnabled
970//
971// The following example configures Amazon SES to Easy DKIM-sign the email sent from
972// an identity:
973func ExampleSES_SetIdentityDkimEnabled_shared00() {
974	svc := ses.New(session.New())
975	input := &ses.SetIdentityDkimEnabledInput{
976		DkimEnabled: aws.Bool(true),
977		Identity:    aws.String("user@example.com"),
978	}
979
980	result, err := svc.SetIdentityDkimEnabled(input)
981	if err != nil {
982		if aerr, ok := err.(awserr.Error); ok {
983			switch aerr.Code() {
984			default:
985				fmt.Println(aerr.Error())
986			}
987		} else {
988			// Print the error, cast err to awserr.Error to get the Code and
989			// Message from an error.
990			fmt.Println(err.Error())
991		}
992		return
993	}
994
995	fmt.Println(result)
996}
997
998// SetIdentityFeedbackForwardingEnabled
999//
1000// The following example configures Amazon SES to forward an identity's bounces and
1001// complaints via email:
1002func ExampleSES_SetIdentityFeedbackForwardingEnabled_shared00() {
1003	svc := ses.New(session.New())
1004	input := &ses.SetIdentityFeedbackForwardingEnabledInput{
1005		ForwardingEnabled: aws.Bool(true),
1006		Identity:          aws.String("user@example.com"),
1007	}
1008
1009	result, err := svc.SetIdentityFeedbackForwardingEnabled(input)
1010	if err != nil {
1011		if aerr, ok := err.(awserr.Error); ok {
1012			switch aerr.Code() {
1013			default:
1014				fmt.Println(aerr.Error())
1015			}
1016		} else {
1017			// Print the error, cast err to awserr.Error to get the Code and
1018			// Message from an error.
1019			fmt.Println(err.Error())
1020		}
1021		return
1022	}
1023
1024	fmt.Println(result)
1025}
1026
1027// SetIdentityHeadersInNotificationsEnabled
1028//
1029// The following example configures Amazon SES to include the original email headers
1030// in the Amazon SNS bounce notifications for an identity:
1031func ExampleSES_SetIdentityHeadersInNotificationsEnabled_shared00() {
1032	svc := ses.New(session.New())
1033	input := &ses.SetIdentityHeadersInNotificationsEnabledInput{
1034		Enabled:          aws.Bool(true),
1035		Identity:         aws.String("user@example.com"),
1036		NotificationType: aws.String("Bounce"),
1037	}
1038
1039	result, err := svc.SetIdentityHeadersInNotificationsEnabled(input)
1040	if err != nil {
1041		if aerr, ok := err.(awserr.Error); ok {
1042			switch aerr.Code() {
1043			default:
1044				fmt.Println(aerr.Error())
1045			}
1046		} else {
1047			// Print the error, cast err to awserr.Error to get the Code and
1048			// Message from an error.
1049			fmt.Println(err.Error())
1050		}
1051		return
1052	}
1053
1054	fmt.Println(result)
1055}
1056
1057// SetIdentityMailFromDomain
1058//
1059// The following example configures Amazon SES to use a custom MAIL FROM domain for
1060// an identity:
1061func ExampleSES_SetIdentityMailFromDomain_shared00() {
1062	svc := ses.New(session.New())
1063	input := &ses.SetIdentityMailFromDomainInput{
1064		BehaviorOnMXFailure: aws.String("UseDefaultValue"),
1065		Identity:            aws.String("user@example.com"),
1066		MailFromDomain:      aws.String("bounces.example.com"),
1067	}
1068
1069	result, err := svc.SetIdentityMailFromDomain(input)
1070	if err != nil {
1071		if aerr, ok := err.(awserr.Error); ok {
1072			switch aerr.Code() {
1073			default:
1074				fmt.Println(aerr.Error())
1075			}
1076		} else {
1077			// Print the error, cast err to awserr.Error to get the Code and
1078			// Message from an error.
1079			fmt.Println(err.Error())
1080		}
1081		return
1082	}
1083
1084	fmt.Println(result)
1085}
1086
1087// SetIdentityNotificationTopic
1088//
1089// The following example sets the Amazon SNS topic to which Amazon SES will publish
1090// bounce, complaint, and/or delivery notifications for emails sent with the specified
1091// identity as the Source:
1092func ExampleSES_SetIdentityNotificationTopic_shared00() {
1093	svc := ses.New(session.New())
1094	input := &ses.SetIdentityNotificationTopicInput{
1095		Identity:         aws.String("user@example.com"),
1096		NotificationType: aws.String("Bounce"),
1097		SnsTopic:         aws.String("arn:aws:sns:us-west-2:111122223333:MyTopic"),
1098	}
1099
1100	result, err := svc.SetIdentityNotificationTopic(input)
1101	if err != nil {
1102		if aerr, ok := err.(awserr.Error); ok {
1103			switch aerr.Code() {
1104			default:
1105				fmt.Println(aerr.Error())
1106			}
1107		} else {
1108			// Print the error, cast err to awserr.Error to get the Code and
1109			// Message from an error.
1110			fmt.Println(err.Error())
1111		}
1112		return
1113	}
1114
1115	fmt.Println(result)
1116}
1117
1118// SetReceiptRulePosition
1119//
1120// The following example sets the position of a receipt rule in a receipt rule set:
1121func ExampleSES_SetReceiptRulePosition_shared00() {
1122	svc := ses.New(session.New())
1123	input := &ses.SetReceiptRulePositionInput{
1124		After:       aws.String("PutRuleAfterThisRule"),
1125		RuleName:    aws.String("RuleToReposition"),
1126		RuleSetName: aws.String("MyRuleSet"),
1127	}
1128
1129	result, err := svc.SetReceiptRulePosition(input)
1130	if err != nil {
1131		if aerr, ok := err.(awserr.Error); ok {
1132			switch aerr.Code() {
1133			case ses.ErrCodeRuleSetDoesNotExistException:
1134				fmt.Println(ses.ErrCodeRuleSetDoesNotExistException, aerr.Error())
1135			case ses.ErrCodeRuleDoesNotExistException:
1136				fmt.Println(ses.ErrCodeRuleDoesNotExistException, aerr.Error())
1137			default:
1138				fmt.Println(aerr.Error())
1139			}
1140		} else {
1141			// Print the error, cast err to awserr.Error to get the Code and
1142			// Message from an error.
1143			fmt.Println(err.Error())
1144		}
1145		return
1146	}
1147
1148	fmt.Println(result)
1149}
1150
1151// UpdateReceiptRule
1152//
1153// The following example updates a receipt rule to use an Amazon S3 action:
1154func ExampleSES_UpdateReceiptRule_shared00() {
1155	svc := ses.New(session.New())
1156	input := &ses.UpdateReceiptRuleInput{
1157		Rule: &ses.ReceiptRule{
1158			Actions: []*ses.ReceiptAction{
1159				{},
1160			},
1161			Enabled:     aws.Bool(true),
1162			Name:        aws.String("MyRule"),
1163			ScanEnabled: aws.Bool(true),
1164			TlsPolicy:   aws.String("Optional"),
1165		},
1166		RuleSetName: aws.String("MyRuleSet"),
1167	}
1168
1169	result, err := svc.UpdateReceiptRule(input)
1170	if err != nil {
1171		if aerr, ok := err.(awserr.Error); ok {
1172			switch aerr.Code() {
1173			case ses.ErrCodeInvalidSnsTopicException:
1174				fmt.Println(ses.ErrCodeInvalidSnsTopicException, aerr.Error())
1175			case ses.ErrCodeInvalidS3ConfigurationException:
1176				fmt.Println(ses.ErrCodeInvalidS3ConfigurationException, aerr.Error())
1177			case ses.ErrCodeInvalidLambdaFunctionException:
1178				fmt.Println(ses.ErrCodeInvalidLambdaFunctionException, aerr.Error())
1179			case ses.ErrCodeRuleSetDoesNotExistException:
1180				fmt.Println(ses.ErrCodeRuleSetDoesNotExistException, aerr.Error())
1181			case ses.ErrCodeRuleDoesNotExistException:
1182				fmt.Println(ses.ErrCodeRuleDoesNotExistException, aerr.Error())
1183			case ses.ErrCodeLimitExceededException:
1184				fmt.Println(ses.ErrCodeLimitExceededException, aerr.Error())
1185			default:
1186				fmt.Println(aerr.Error())
1187			}
1188		} else {
1189			// Print the error, cast err to awserr.Error to get the Code and
1190			// Message from an error.
1191			fmt.Println(err.Error())
1192		}
1193		return
1194	}
1195
1196	fmt.Println(result)
1197}
1198
1199// VerifyDomainDkim
1200//
1201// The following example generates DKIM tokens for a domain that has been verified with
1202// Amazon SES:
1203func ExampleSES_VerifyDomainDkim_shared00() {
1204	svc := ses.New(session.New())
1205	input := &ses.VerifyDomainDkimInput{
1206		Domain: aws.String("example.com"),
1207	}
1208
1209	result, err := svc.VerifyDomainDkim(input)
1210	if err != nil {
1211		if aerr, ok := err.(awserr.Error); ok {
1212			switch aerr.Code() {
1213			default:
1214				fmt.Println(aerr.Error())
1215			}
1216		} else {
1217			// Print the error, cast err to awserr.Error to get the Code and
1218			// Message from an error.
1219			fmt.Println(err.Error())
1220		}
1221		return
1222	}
1223
1224	fmt.Println(result)
1225}
1226
1227// VerifyDomainIdentity
1228//
1229// The following example starts the domain verification process with Amazon SES:
1230func ExampleSES_VerifyDomainIdentity_shared00() {
1231	svc := ses.New(session.New())
1232	input := &ses.VerifyDomainIdentityInput{
1233		Domain: aws.String("example.com"),
1234	}
1235
1236	result, err := svc.VerifyDomainIdentity(input)
1237	if err != nil {
1238		if aerr, ok := err.(awserr.Error); ok {
1239			switch aerr.Code() {
1240			default:
1241				fmt.Println(aerr.Error())
1242			}
1243		} else {
1244			// Print the error, cast err to awserr.Error to get the Code and
1245			// Message from an error.
1246			fmt.Println(err.Error())
1247		}
1248		return
1249	}
1250
1251	fmt.Println(result)
1252}
1253
1254// VerifyEmailAddress
1255//
1256// The following example starts the email address verification process with Amazon SES:
1257func ExampleSES_VerifyEmailAddress_shared00() {
1258	svc := ses.New(session.New())
1259	input := &ses.VerifyEmailAddressInput{
1260		EmailAddress: aws.String("user@example.com"),
1261	}
1262
1263	result, err := svc.VerifyEmailAddress(input)
1264	if err != nil {
1265		if aerr, ok := err.(awserr.Error); ok {
1266			switch aerr.Code() {
1267			default:
1268				fmt.Println(aerr.Error())
1269			}
1270		} else {
1271			// Print the error, cast err to awserr.Error to get the Code and
1272			// Message from an error.
1273			fmt.Println(err.Error())
1274		}
1275		return
1276	}
1277
1278	fmt.Println(result)
1279}
1280
1281// VerifyEmailIdentity
1282//
1283// The following example starts the email address verification process with Amazon SES:
1284func ExampleSES_VerifyEmailIdentity_shared00() {
1285	svc := ses.New(session.New())
1286	input := &ses.VerifyEmailIdentityInput{
1287		EmailAddress: aws.String("user@example.com"),
1288	}
1289
1290	result, err := svc.VerifyEmailIdentity(input)
1291	if err != nil {
1292		if aerr, ok := err.(awserr.Error); ok {
1293			switch aerr.Code() {
1294			default:
1295				fmt.Println(aerr.Error())
1296			}
1297		} else {
1298			// Print the error, cast err to awserr.Error to get the Code and
1299			// Message from an error.
1300			fmt.Println(err.Error())
1301		}
1302		return
1303	}
1304
1305	fmt.Println(result)
1306}
1307