MCPcopy Create free account
hub / github.com/awsdocs/aws-doc-sdk-examples / SesIdentity

Class SesIdentity

python/example_code/ses/ses_identities.py:19–151  ·  view source on GitHub ↗

Encapsulates Amazon SES identity functions.

Source from the content-addressed store, hash-verified

17
18# snippet-start:[python.example_code.ses.SesIdentity]
19class SesIdentity:
20 """Encapsulates Amazon SES identity functions."""
21
22 def __init__(self, ses_client):
23 """
24 :param ses_client: A Boto3 Amazon SES client.
25 """
26 self.ses_client = ses_client
27
28 # snippet-end:[python.example_code.ses.SesIdentity]
29
30 # snippet-start:[python.example_code.ses.VerifyDomainIdentity]
31 def verify_domain_identity(self, domain_name):
32 """
33 Starts verification of a domain identity. To complete verification, you must
34 create a TXT record with a specific format through your DNS provider.
35
36 For more information, see *Verifying a domain with Amazon SES* in the
37 Amazon SES documentation:
38 https://docs.aws.amazon.com/ses/latest/DeveloperGuide/verify-domain-procedure.html
39
40 :param domain_name: The name of the domain to verify.
41 :return: The token to include in the TXT record with your DNS provider.
42 """
43 try:
44 response = self.ses_client.verify_domain_identity(Domain=domain_name)
45 token = response["VerificationToken"]
46 logger.info("Got domain verification token for %s.", domain_name)
47 except ClientError:
48 logger.exception("Couldn't verify domain %s.", domain_name)
49 raise
50 else:
51 return token
52
53 # snippet-end:[python.example_code.ses.VerifyDomainIdentity]
54
55 # snippet-start:[python.example_code.ses.VerifyEmailIdentity]
56 def verify_email_identity(self, email_address):
57 """
58 Starts verification of an email identity. This function causes an email
59 to be sent to the specified email address from Amazon SES. To complete
60 verification, follow the instructions in the email.
61
62 :param email_address: The email address to verify.
63 """
64 try:
65 self.ses_client.verify_email_identity(EmailAddress=email_address)
66 logger.info("Started verification of %s.", email_address)
67 except ClientError:
68 logger.exception("Couldn't start verification of %s.", email_address)
69 raise
70
71 # snippet-end:[python.example_code.ses.VerifyEmailIdentity]
72
73 # snippet-start:[python.example_code.ses.helper.wait_until_identity_exists]
74 def wait_until_identity_exists(self, identity):
75 """
76 Waits until an identity exists. The waiter polls Amazon SES until the

Callers 8

usage_demoFunction · 0.90
test_get_identity_statusFunction · 0.90
test_delete_identityFunction · 0.90
test_list_identitiesFunction · 0.90
usage_demoFunction · 0.85

Calls

no outgoing calls

Tested by 6

test_get_identity_statusFunction · 0.72
test_delete_identityFunction · 0.72
test_list_identitiesFunction · 0.72