I am trying to set up amazon SES recipient rule set for putting emails into an s3 bucket. I have created an s3 bucket and I want these mails to sent into folders according to the email id. For example if an email is coming to 1@mydomain.com it should go into mytestbucket/1 and if it is coming to 2@mydomain.com it should go into 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;
}
Whenever I add a customer I was calling this method to create a rule to my active ruleset. But it looks like only 100 rules can be added. My usecase will be for at least 100 000. How can I achieve this?
Something I am expecting to do is
Have a single recipient rule which says any email comes to mysubdomain invoke a lambda function
Lambda function should put the email into subfolders of s3
Follow these steps to achieve what you desire...
Create a single SES rule to place ALL emails into a single S3 folder
unsorted_emails
(you can call it anything).Create a Lambda function that places emails into their proper folders.
Set
unsorted_emails
as an event source to trigger your lambda function.Now, whenever new emails are added to
unsorted_emails
, your lambda function will be triggered and move the email into a proper folder.Let me know if these steps make sense, if you have any questions, or if I can clarify more.