30

I am searching a way to redirect email which are sent to a domain whose DNS is Amazon's Route 53 service. E.g. I would like to redirect the email me@example.com to myname@gmail.com. And second@example.com to whatever@live.com. Is this possible to do with Amazon's Simple EMail Services (SES)? Is there another way to do with with AWS services (except setting up an email server on EC2)?

David Graf
  • 1,052
  • 2
  • 13
  • 22

4 Answers4

27

SES is not able to redirect messages by itself, but can call Lambda function and it can redirect message.

There is ready to use Lambda function: https://github.com/arithmetric/aws-lambda-ses-forwarder

Bobík
  • 1,345
  • 15
  • 15
  • 1
    That lambda function doesn't work for me. SES requires all sender addresses to be pre-verified and throws an exception. – Scott Klarenbach Feb 17 '16 at 20:53
  • 1
    Is it also possible to point it to an SNS that has an email subscriber? – Sarsaparilla May 17 '17 at 17:45
  • 1
    Currently this lambda function adds a Reply-To header with the original sender and changes the the From header so it should also work for not verified sender addresses. – gonz May 31 '17 at 15:18
  • 2
    @Scott Better explained in Limitations section in README. – Bobík Dec 19 '17 at 13:59
11

I had this problem recently (July 2019), and googling it brought me here. The answer was not so obvious to me, so here is how I configured my domain on Route 53 to both receive and send email with my email account at gmail:

Receive email: Use improvMX to forward all emails directed at *@yourdomain.com to your personal mail. I have found this by looking at this answer. You only change your MX records on Route 53 and setup a free account on improvMX. improvMX will then forward all the email directed at your domain to your personal email. You can also select specific mail addresses for forwarding like hello@mydomain.com. This is way easier than you think. It took me literally 5 minutes.

Send email: Amazon SES service is basically a SMTP server for sending mails. So if your domain is on Route 53, then using Amazon SES is really easy. Here is the Amazon SES doc for sending mail using SMTP. Basic steps for connecting SES with gmail:

  1. Create an IAM user as explained in the AWS doc, which will give you a username and a password.
  2. In your gmail account add another email address to send as.
  3. Uncheck "Treat as an alias". (When checked, gmail will try to receive emails from SES, which won't work.)
  4. Use SES's SMTP server address for SMTP server, and IAM credentials obtained previously for username and password.
  5. You're done! Now you can send emails using myname@mydomain.com from gmail.

Additional note here: In order to send mail using SES you need to get your SES account out of sandbox.

I know the question only asked for receiving emails, but I figured someone might be looking to do both receiving and sending, like me, so I hope this answer helps someone.

obayram
  • 111
  • 2
  • 5
10

This email redirection is the "missing feature" of the AWS platform, but there is a "free" workaround that will provide the redirection for you. Create an account with mailgun (free for under 10 000 emails a month) and when you set up your domain, you can redirect it to the mailgun servers (which is very clearly explained in their documentation). You can then use a combination of what they call "routes" to setup any combination of redirects based on:

  1. Email name being sent to john@foo.com or jane@foo.com
  2. Subject of the email
  3. Various properties of the email header

I was fully ready to give up on having email accounts under my Route 53 domain, but this worked perfectly for me.

Duncan Edwards
  • 1,496
  • 2
  • 18
  • 31
  • 5
    Amazon announced that SES is able to receive emails. It is possible to redirect it? – shark Dec 13 '15 at 16:16
  • 1
    I had a bit of a look at the email receipt rules and it just doesn't look like redirecting to another email address is supported out of the box. It sounds like you could write a Lambda rule that does this but I'm not going to bother as the way above works fine for the small percentage of stuff that comes through the catchall. – Duncan Edwards Feb 08 '17 at 15:45
  • 2
    Mailgun costs 35$ per month for inbound emails – jontro Jun 03 '20 at 22:56
  • 2
    Mailgun has discontinued the free "routes" options, so now you are stuck with paying $35+ USD to use this unfortunately. It worked great until they made this change. – Onitlikesonic Sep 18 '20 at 00:31
  • In addition to forwarding to Lambda, SES can set/overwrite headers in the email. I wonder, if the TO header was modified then if the email would be forwarded elsewhere automatically (without needing to use Lambda to push the email back out via SES again or some SMTP server) – sudo soul Dec 01 '20 at 05:58
0

AWS have documented how to do this using a lambda written in Python

https://aws.amazon.com/blogs/messaging-and-targeting/forward-incoming-email-to-an-external-destination/

fiat
  • 13,753
  • 6
  • 72
  • 94