是的,AWS Simple Email Service (SES) 支持使用 S/MIME 对电子邮件进行签名和加密。
以下是一个使用 AWS SDK for Python (Boto3) 的示例代码,演示如何使用 S/MIME 对邮件进行签名和加密:
import boto3
def send_signed_and_encrypted_email(sender, recipient, subject, body):
# 创建 SES 客户端
client = boto3.client('ses')
# 创建 S/MIME 模板
template = {
'Template': {
'TemplateName': 'MySMIMETemplate',
'SubjectPart': subject,
'TextPart': body,
'HtmlPart': '' + body + ''
}
}
# 创建 S/MIME 模板
response = client.create_template(**template)
template_arn = response['Template']['TemplateArn']
# 使用 S/MIME 模板发送电子邮件
response = client.send_templated_email(
Source=sender,
Destination={
'ToAddresses': [
recipient,
]
},
Template='MySMIMETemplate',
TemplateData='{"name":"Alice"}',
ConfigurationSetName='MyConfigurationSet',
Tags=[
{
'Name': 'tag-name',
'Value': 'tag-value'
},
]
)
print(response)
你需要根据自己的需求修改代码中的参数,例如发件人、收件人、主题和正文。还需要确保你已经设置好 AWS 凭证并正确配置 Boto3。
请注意,使用 S/MIME 对电子邮件进行签名和加密需要在 AWS SES 控制台上创建 S/MIME 模板,并在创建模板时上传你的 S/MIME 证书。