I am trying to invoke AWS Lambda function whenever I recieve an email in my outlook account. While following AWS documentation I found there are two ways to do so either to publish the MX record or to explicitly route it. In my case I have already published MX between outlook and my private domain. So I was trying for the second method.
In outlook forwarding rule what SES address needs to be given? Is it something@inbound-smtp.us-east-1.amazonaws.com or something else
The forwarding rule method mentioned is not similar to standard email address forwarding where you can configure someone@email.com to have all its emails forwarded/sent to someone-else@email.com.
Instead, it is referring specifically to a method known as SMTP Relaying
.
That said though, if you have successfully pointed the MX record, then you do not need to configure an additional SMTP Relay. You do, however, need to create necessary rules in SES in order to specify the specific email addresses on the domain that you wish to process inbound email for.
Below is an example of a common Active Rule Set configuration that saves the incoming email to S3 to be processed by a specific Lambda function:
- Rule Name: saveToS3 (you can name it anything):
- Choose the email addresses
(recipients)
this rule should apply to.
- Select
S3
as the Action Type.
- Choose/Create the S3 Bucket to Save the Email Messages to.
- Note: You can alternatively use SNS to save the email messages in.
- Save Rule.
- Rule Name: invokeLambda (you can name it anything):
- Choose the email addresses
(recipients)
this rule should apply to.
- Select
Lambda
as the Action Type.
- Choose the Lambda function to be invoked after SES has saved the email body to S3 (Lambda cannot directly access the body content of the email, this is why it must first be saved in either S3 OR SNS).
- Save Rule.
- Rule Name: EndRuleFlow (you can name it anything):
- Choose the email addresses
(recipients)
this rule should apply to.
- Select
Stop Rule
as the Action Type.
- Save Rule.
Once these rules are set, and assuming that you have correctly verified the domain and properly pointed the MX records, SES will begin receiving all incoming email for the email addresses specified in the active rule set.
Feel free to refer to this AWS Blog Post for more information on receiving email with SES and processing it with Lambda.