I am trying to use SES to intercept an incoming email for a domain, do some processing and manipulation of the email with a lambda, then would like to continue sending the email to the final destination / original mail server.
- Say I own mydomain.com
- mydomain.com uses Google Mail services (GSuite)
- I set the mydomain.com MX records to point SES from GSuite
- email@example.com sends an email to firstname.lastname@example.org
- email is received by SES and is processed by lambda
- lambda then sends the email to the original Gsuite mailserver
- end result is email@example.com receives an email in gmail from firstname.lastname@example.org (possibly with some elements of the email redacted by the lambda)
The main issue here being that the mydomain.com MX record would then point to SES and upon sending within the lambda the message would then send to SES not the original mail server.
Is there a good way around this problem? Is there a better best practice relating to the use case above, intercepting and manipulating emails? I'm also unsure if "Inbound Mail Gateway" is the correct term to describe my use case.