public void sendCouponNewsletter() {
    try {
      // Retrieve the list of contacts from the "weekly-coupons-newsletter" contact
      // list
      // snippet-start:[sesv2.java2.newsletter.ListContacts]
      ListContactsRequest contactListRequest = ListContactsRequest.builder()
          .contactListName(CONTACT_LIST_NAME)
          .build();

      List<String> contactEmails;
      try {
        ListContactsResponse contactListResponse = sesClient.listContacts(contactListRequest);

        contactEmails = contactListResponse.contacts().stream()
            .map(Contact::emailAddress)
            .toList();
      } catch (Exception e) {
        // TODO: Remove when listContacts's GET body issue is resolved.
        contactEmails = this.contacts;
      }

      // snippet-end:[sesv2.java2.newsletter.ListContacts]

      // Send an email using the "weekly-coupons" template to each contact in the list
      // snippet-start:[sesv2.java2.newsletter.SendEmail.template]
      String coupons = Files.readString(Paths.get("resources/coupon_newsletter/sample_coupons.json"));
      for (String emailAddress : contactEmails) {
        SendEmailRequest newsletterRequest = SendEmailRequest.builder()
            .destination(Destination.builder().toAddresses(emailAddress).build())
            .content(EmailContent.builder()
                .template(Template.builder()
                    .templateName(TEMPLATE_NAME)
                    .templateData(coupons)
                    .build())
                .build())
            .fromEmailAddress(this.verifiedEmail)
            .listManagementOptions(ListManagementOptions.builder()
                .contactListName(CONTACT_LIST_NAME)
                .build())
            .build();
        SendEmailResponse newsletterResponse = sesClient.sendEmail(newsletterRequest);
        System.out.println("Newsletter sent to " + emailAddress + ": " + newsletterResponse.messageId());
      }
      // snippet-end:[sesv2.java2.newsletter.SendEmail.template]
    } catch (NotFoundException e) {
      // If the contact list does not exist, fail the workflow and inform the user
      System.err.println("The contact list is missing. Please create the contact list and try again.");
    } catch (AccountSuspendedException e) {
      // If the account is suspended, fail the workflow and inform the user
      System.err.println("Your account is suspended. Please resolve the issue and try again.");
    } catch (MailFromDomainNotVerifiedException e) {
      // If the sending domain is not verified, fail the workflow and inform the user
      System.err.println("The sending domain is not verified. Please verify your domain and try again.");
      throw e;
    } catch (MessageRejectedException e) {
      // If the message is rejected due to invalid content, fail the workflow and
      // inform the user
      System.err.println("The message content is invalid. Please check your template and try again.");
      throw e;
    } catch (SendingPausedException e) {
      // If sending is paused, fail the workflow and inform the user
      System.err.println("Sending is currently paused for your account. Please resolve the issue and try again.");
      throw e;
    } catch (Exception e) {
      System.err.println("Error occurred while sending the newsletter: " + e.getMessage());
      e.printStackTrace();
    }
  }
@Test
  public void test_sendCouponNewsletter_error_domainNotVerified() {
    // Mock the necessary AWS SDK calls and responses
    CreateEmailTemplateResponse templateResponse = CreateEmailTemplateResponse.builder().build();
    when(sesClient.createEmailTemplate(any(CreateEmailTemplateRequest.class))).thenReturn(templateResponse);

    ListContactsResponse contactListResponse = ListContactsResponse.builder()
        .contacts(Contact.builder().emailAddress("user@example.com").build())
        .build();
    when(sesClient.listContacts(any(ListContactsRequest.class))).thenReturn(
        contactListResponse);

    when(sesClient.sendEmail(any(SendEmailRequest.class))).thenThrow(
        MailFromDomainNotVerifiedException.class);

    try {
      scenario.sendCouponNewsletter();
    } catch (Exception e) {
    }

    String errorOutput = errContent.toString();
    assertThat(errorOutput,
        containsString("The sending domain is not verified. Please verify your domain and try again."));
  }