AWS SES允许为每个域名配置多个发件人地址,但是每个发件人地址必须单独验证。因此,如果想要在一个“domain_identity”下配置多个“mail_from_domain”地址,您需要分别验证每个发件人地址,以便将其添加到该域的配置中。
以下是一个示例代码,用于向AWS SES验证两个发件人地址,并将它们添加到同一域的配置中。
import boto3
ses_client = boto3.client('ses')
# Verify the first email address
response = ses_client.verify_email_identity(EmailAddress='first@example.com')
# Wait until the verification is complete
ses_client.get_waiter('email_exists').wait(EmailAddress='first@example.com')
# Verify the second email address
response = ses_client.verify_email_identity(EmailAddress='second@example.com')
# Wait until the verification is complete
ses_client.get_waiter('email_exists').wait(EmailAddress='second@example.com')
# Add the email addresses to the domain identity
response = ses_client.set_identity_mail_from_domain(
Identity='example.com',
MailFromDomainConfigurations=[
{
'MailFromDomain': 'first@example.com',
'BehaviorOnMXFailure': 'UseDefaultValue'
},
{
'MailFromDomain': 'second@example.com',
'BehaviorOnMXFailure': 'UseDefaultValue'
}
]
)
此代码使用AWS SDK for Python(Boto3)验证两个发件人地址(“first@example.com”和“second@example.com”),然后将它们添加到域名“example.com”的配置中。
注意:如果您已经验证了一个发件人地址,并希望添加另一个发件人地址,则只需重复上述步骤即可。