AWS SES with namecheap domain receive mail

1.8k Views Asked by At

I have followed all instruction, added 4 CNAME, 1 TXT Record, 1 Custom MX. After that I installed aws workmail, and i can send emails to anyone as account is activated, it's not in sandbox. When someone else send email to workmail(reply to email we sent) that email never arrive and in gmail we didn't receive the error email that it's not received.

1

There are 1 best solutions below

0
On

You can get it to work with a mix of S3, SES, and Lambda. It's pretty convoluted.

Here's an AWS article on how to do it: https://aws.amazon.com/blogs/messaging-and-targeting/forward-incoming-email-to-an-external-destination/

These are the general steps you'll take:

1) you must have your domain verified in SES

2) create an mx record on NameCheap (values to use are in the link above): namecheap mx record

3) create an s3 bucket to store emails with policies laid out in link above

4) create rule set in SES to save emails to bucket (Under Email Receiving in left menu)

5) create lambda function to forward emails. Unlike the article above I used Node here. My solution is based on this: https://github.com/arithmetric/aws-lambda-ses-forwarder. This is my package.json:

{
  "name": "aws-lambda-ses-forwarder-example",
  "version": "1.0.0",
  "description": "Example implementation of aws-lambda-ses-forwarder.",
  "main": "index.js",
  "dependencies": {
    "aws-lambda-ses-forwarder": "^3.0.0"
  }
}

And this in my index.js:

var LambdaForwarder = require("aws-lambda-ses-forwarder");

exports.handler = function(event, context) {
  // Configure the S3 bucket and key prefix for stored raw emails, and the
  // mapping of email addresses to forward from and to.
  //
  // Expected keys/values:
  // - fromEmail: Forwarded emails will come from this verified address
  // - emailBucket: S3 bucket name where SES stores emails.
  // - emailKeyPrefix: S3 key name prefix where SES stores email. Include the
  //   trailing slash.
  // - forwardMapping: Object where the key is the email address from which to
  //   forward and the value is an array of email addresses to which to send the
  //   message.
  var overrides = {
    config: {
      fromEmail: "", // Email address using your domain
      subjectPrefix: "",
      emailBucket: "", // S3 email bucket name
      emailKeyPrefix: "emails/", // Replace with "Object key prefix" set in SES and add a forward slash
      forwardMapping: {
        "@domain.com": [ // Use your domain here
          "[email protected]" // email to forward to
        ],
        "@domain2.com": [ // you can add more domains to forward from (explained below *)
          "[email protected]"
        ],
      }
    }
  };
  LambdaForwarder.handler(event, context, overrides);
};
  • You can use this to forward emails from multiple domains. Let's say you have 2 namecheap domains. Follow steps 1 & 2 for each domain. Then as long as you have both domains as properties of "forwardMapping", they will both be forwarded to you. All emails will be sent from the email listed in "fromEmail", regardless of domain.

6) In lambda, set the "Handler" value to index.handler