要在AWS SES虚拟交付管理器仪表板中仅显示选择性消息,您可以使用AWS SDK或AWS CLI创建一个配置集,并在发送电子邮件时将此配置集与您的消息关联。
以下是使用AWS SDK for Python(Boto3)的示例代码:
import boto3
def create_configuration_set():
ses_client = boto3.client('ses')
response = ses_client.create_configuration_set(
ConfigurationSetName='SelectiveMessages'
)
return response['ConfigurationSet']['Name']
def send_email():
ses_client = boto3.client('ses')
# 创建一个配置集
configuration_set_name = create_configuration_set()
# 发送电子邮件时将配置集与消息关联
response = ses_client.send_email(
Source='sender@example.com',
Destination={
'ToAddresses': ['recipient@example.com']
},
Message={
'Subject': {
'Data': 'Hello from SES'
},
'Body': {
'Text': {
'Data': 'This is a selective message'
}
}
},
ConfigurationSetName=configuration_set_name
)
print(response)
send_email()
上述代码中,我们使用create_configuration_set
函数创建了一个名为"SelectiveMessages"的配置集。然后,我们在发送电子邮件时将此配置集与消息一起发送,通过在send_email
函数中设置ConfigurationSetName
参数。
此配置集将用于标识仅显示选择性消息的电子邮件。您可以在AWS SES虚拟交付管理器仪表板中选择该配置集,以仅显示与该配置集关联的消息。
请注意,您需要安装并配置AWS SDK for Python(Boto3)才能运行上述代码。