Search code examples
amazon-web-servicesapiemailaws-lambdaamazon-ses

Integrate private email notifications with Lambda


I'm currently seeking a solution to trigger a Lambda function whenever I receive an email from a specific recipient. The email account I'm using is within the Gmail domain. Is there a way to integrate a private email account with Lambda?

I came across a solution provided by Google Cloud Platform (GCP) for Gmail, which can be found here: GCP Gmail API Push Guide. While this solution works well for Gmail, I'm wondering if there is a similar approach available for any private email account.

Do I need to create an email server within AWS to integrate it with SES (Simple Email Service) and subsequently with Lambda?

Background:

I am designing a solution for automated replies in a specific site's API. Whenever I receive a message on this site, I would like to reply with a generic message directly through the site. The site only supports push notifications via email and phone, which is why I'm interested in integrating a private email account with Lambda. My goal is to trigger the Lambda function only when a new message arrives, rather than periodically checking for new messages every hour or minute.

I have tried with GMAIL and GCP: https://developers.google.com/gmail/api/guides/push


Solution

  • I successfully resolved this issue using the following approach. This can be resolved by utilizing Amazon SES (Simple Email Service) along with your own domain. Here are the steps you can follow:

    1. Purchase a domain through the AWS Registrar service.
    2. Add the purchased domain to the verified identities in Amazon SES.
    3. Configure Amazon SES to receive incoming emails for your domain.
    4. Optionally, you can set up filters or actions within Amazon SES to further process the received emails.

    By implementing this setup, all incoming emails addressed to your domain will be routed through Amazon SES. You can then leverage AWS Lambda or other services to perform additional filtering or take desired actions based on your requirements.

    Note: It's important to configure the necessary DNS settings for your domain to ensure proper email routing and delivery.