是的,Amazon SES支持加号地址,也被称为Sub-addressing。您可以在你的SES邮件地址添加一个加号和任何字符串来创建一个唯一的地址。
以下是一个使用Python发送电子邮件到Amazon SES的示例代码,其中包括加号地址:
import boto3
from botocore.exceptions import ClientError
# Create an SES client
client = boto3.client('ses')
# Create message
message = {
'Subject': {
'Data': 'Testing sub-addressing with Amazon SES'
},
'Body': {
'Text': {
'Data': 'This email was sent to user+uniqueId@example.com'
}
}
}
# Try to send the email
try:
response = client.send_email(
Source='sender@example.com',
Destination={
'ToAddresses': [
'user+uniqueId@example.com'
]
},
Message=message
)
except ClientError as e:
print(e.response['Error']['Message'])
else:
print("Email sent! Message ID:", response['MessageId'])
在上面的示例中,电子邮件发送到了 'user+uniqueId@example.com' 地址,其中 'uniqueId' 可替换为任何字符串。
请注意,虽然Amazon SES支持加号地址,但某些电子邮件系统或服务提供商可能不支持,因此您需要在发送电子邮件时谨慎使用加号地址,以确保接收方能够正确接收您的邮件。