我正在尝试设置亚马逊SES收件人规则集,以便将电子邮件放入s3存储桶中。我创建了一个s3存储桶,我想根据电子邮件ID将这些邮件发送到文件夹中。例如,如果电子邮件发送到 1@mydomain.com ,则应该进入 mytestbucket / 1 ,如果它来到 2@mydomain.com 它应该进入 mytestbucket / 2 。
AWSCredentials awsCredentials = new BasicAWSCredentials(accessKey, secretKey);
AmazonSimpleEmailServiceClient sesClient = new AmazonSimpleEmailServiceClient(awsCredentials);
;
if (sesClient != null) {
CreateReceiptRuleRequest req = new CreateReceiptRuleRequest();
req.withRuleSetName(ruleSetName);
ReceiptRule rule = new ReceiptRule();
rule.setEnabled(true);
rule.setName(customerIdString + "-email");
rule.withRecipients(customerIdString + "@" + mydomain.com);
List<ReceiptAction> actions = new ArrayList<ReceiptAction>();
ReceiptAction action = new ReceiptAction();
S3Action s3Action = new S3Action();
s3Action.setBucketName(mytestbucket);
s3Action.setObjectKeyPrefix(customerIdString);
action.setS3Action(s3Action);
actions.add(action);
rule.setActions(actions);
req.setRule(rule);
CreateReceiptRuleResult response = sesClient.createReceiptRule(req);
return true;
}
每当我添加一个客户时,我都会调用此方法来为我的活动规则集创建规则。但看起来只能添加100条规则。我的用例将至少为10万。我怎样才能做到这一点?
我期待的事情是
有一个收件人规则,说明任何发送到mysubdomain的电子邮件都会调用lambda函数
Lambda函数应将电子邮件放入s3的子文件夹
答案 0 :(得分:1)
按照以下步骤实现您的目标......
创建单个SES规则,将所有电子邮件放入单个S3文件夹unsorted_emails
(您可以将其称为任何内容)。
创建一个Lambda函数,将电子邮件放入正确的文件夹中。
将unsorted_emails
设置为事件源以触发lambda函数。
现在,只要将新电子邮件添加到unsorted_emails
,就会触发您的lambda函数并将电子邮件移动到正确的文件夹中。
如果您有任何疑问,或者我可以澄清更多内容,请告诉我这些步骤是否有意义。