再会!我刚开始使用 Amazon SES。我想在我的 asp.net mvc (C#) 网站中使用它。
我下载并安装 AWS Toolkit for Visual Studio,创建 AWS 简单控制台应用程序。因此,我有可以使用 AmazonSimpleEmailService 客户端发送电子邮件的示例代码。
第1部分:
using (AmazonSimpleEmailService client = AWSClientFactory.CreateAmazonSimpleEmailServiceClient(RegionEndpoint.USEast1))
{
var sendRequest = new SendEmailRequest
{
Source = senderAddress,
Destination = new Destination { ToAddresses = new List<string> { receiverAddress } },
Message = new Message
{
Subject = new Content("Sample Mail using SES"),
Body = new Body { Text = new Content("Sample message content.") }
}
};
Console.WriteLine("Sending email using AWS SES...");
SendEmailResponse response = client.SendEmail(sendRequest);
Console.WriteLine("The email was sent successfully.");
}
此外,我必须通过 Amazon SNS 配置 Amazon SES 反馈通知。我用示例代码找到了很好的主题:
第 3 部分: http ://sesblog.amazon.com/post/TxJE1JNZ6T9JXK/Handling-Bounces-and-Complaints
所以,我需要在第 2 部分中获得 ReceiveMessageResponse 响应并将其发送到第 3 部分。
我需要在 C# 中实现以下步骤:设置以下 AWS 组件来处理退回通知:
1. Create an Amazon SQS queue named ses-bounces-queue.
2. Create an Amazon SNS topic named ses-bounces-topic.
3. Configure the Amazon SNS topic to publish to the SQS queue.
4. Configure Amazon SES to publish bounce notifications using ses-bounces-topic to ses-bounces-queue.
我试着写:
// 1. Create an Amazon SQS queue named ses-bounces-queue.
AmazonSQS sqs = AWSClientFactory.CreateAmazonSQSClient(RegionEndpoint.USWest2);
CreateQueueRequest sqsRequest = new CreateQueueRequest();
sqsRequest.QueueName = "ses-bounces-queue";
CreateQueueResponse createQueueResponse = sqs.CreateQueue(sqsRequest);
String myQueueUrl;
myQueueUrl = createQueueResponse.CreateQueueResult.QueueUrl;
// 2. Create an Amazon SNS topic named ses-bounces-topic
AmazonSimpleNotificationService sns = new AmazonSimpleNotificationServiceClient(RegionEndpoint.USWest2);
string topicArn = sns.CreateTopic(new CreateTopicRequest
{
Name = "ses-bounces-topic"
}).CreateTopicResult.TopicArn;
// 3. Configure the Amazon SNS topic to publish to the SQS queue
sns.Subscribe(new SubscribeRequest
{
TopicArn = topicArn,
Protocol = "https",
Endpoint = "ses-bounces-queue"
});
// 4. Configure Amazon SES to publish bounce notifications using ses-bounces-topic to ses-bounces-queue
clientSES.SetIdentityNotificationTopic(XObject);
我在正确的轨道上?
我如何实施 4 部分?如何接收 XObject?
谢谢!