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