问题描述:我们使用AWS .Net Core SDK中的Simple Email Service (SES)发送电子邮件,但发现抑制列表失败,即尽管我们将某些电子邮件地址列入抑制列表,仍会向它们发送电子邮件。
解决方案:为了成功地将电子邮件地址添加到邮件的抑制列表中,我们需要确保邮件地址正确添加。以下是一个基本的代码示例:
var sendRequest = new SendEmailRequest
{
Destination = new Destination
{
ToAddresses = new List { "recipient@example.com" }
},
Message = new Message
{
Body = new Body
{
Html = new Content { Charset = "UTF-8", Data = "Sample email
This email was sent using the AWS SDK for .NET.
" }
},
Subject = new Content { Charset = "UTF-8", Data = "Test email" }
},
Source = "sender@example.com",
ConfigurationSetName = "ConfigSet"
};
// Create an instance of the Amazon Simple Email Service (SES) client
var client = new AmazonSimpleEmailServiceClient(RegionEndpoint.USWest2);
// Add email address to suppression list
var request = new UpdateConfigurationSetSuppressionListRequest
{
ConfigurationSetName = sendRequest.ConfigurationSetName,
SuppressionListReason = "BouncedMessage",
SuppressedEmailAddress = "recipient@example.com"
};
// Call SES to add the email address to suppression list
var response = await client.UpdateConfigurationSetSuppressionListAsync(request);
// Send the email
var sendResponse = await client.SendEmailAsync(sendRequest);
需要注意几个重点:
上一篇:AWS.NetCoreSDKAmazonS3.DeleteObjects静默失败
下一篇:AWS.NET微服务提取工具出现异常“Cannotcallwriteafterastreamwasdestroyed”