aws-lambda-ses-forwarder icon indicating copy to clipboard operation
aws-lambda-ses-forwarder copied to clipboard

Functionality request - AWS store and forward for backup MX

Open marcwilson1000 opened this issue 7 years ago • 3 comments

Hi Joe

I am interested in using your code to create a store and forward backup MX on AWS.

As far as I can tell, this would require changing the code to forward to the original addressee. This would appear trivial.

The major difference I think is that the forward would need to be triggered by a poll on the main MX showing it is up and then looping through all emails in the S3 bucket rather than just forwarding the one email in the current code.

I think the store and forward requirement is typical. There may be other code that does this.

If not I'm prepared to contribute to beer money...

marcwilson1000 avatar Jan 28 '18 20:01 marcwilson1000

Did you try just to use same recipient in mapping configuration?

Example:

forwardMapping: {
    "[email protected]": [
      "[email protected]" // same address
    ]
  }

I didn't try it yer, but it can maybe solve your request. Maybe.

jakubboucek avatar Jan 28 '18 21:01 jakubboucek

Oh, my bad english. I wrong understand your request. My shame.

I suggest use another access than rewrite code of this tool, because AWS Lambda is great to solve simple atomic task, but "looping through all emails in the S3 bucket" can escalate to big load exceeded Lambda limits.

Attach to SES Receive Rule the SQS service instead of Lambda function. One of SQS features is Message timers which can delay message up to 15 minutes (it is posible hackable via DLQ if you need bigger delay).

But it require make separate Lambda function for pooling SQS queue repeately to check if if any message is waiting. Thas Lambda receive message from queue and invoke this SES Forwarder.

Inspiration is posible here: https://riston.github.io/post/lambda-sqs-handler/

jakubboucek avatar Jan 28 '18 21:01 jakubboucek

Hi Jakub

Thanks for the reply.

What about using a scheduled trigger of a modified version of this script?

I'm a bit initidated by setting up the SQS service and rewriting from scratch.

I'm not java capable, but it would seem that the modification would be the following:

Could the forward mapping be automated to forward to the original address rather than through static code?

exports.parseEvent would need to be replaced with a loop that queries the top raw email in the bucket and then calls the other steps to process this.

The loop would seem to look something like this: https://stackoverflow.com/questions/43125253/amazon-ses-process-emails-stored-in-s3

Could the function could be scheduled to run on a regular schedule: https://docs.aws.amazon.com/lambda/latest/dg/with-scheduled-events.html

marcwilson1000 avatar Feb 24 '18 21:02 marcwilson1000