KJ Ang
KJ Ang

Reputation: 638

Can I use any email under my domain name to send emails using AWS SES?

Pardon me if I am asking a pretty dumb question. I am new to SES and I could not find a straight answer in the AWS docs about this.

Some background info: I am using node server on EC2. I own a domain, let's say "mydomain.com". I only need AWS SES to send out emails to my customers and I plan to use AWS-SDK in my EC2 server to talk to SES. I do not need to receive any emails from customers.

According to AWS SES docs, I only need to verify either my domain OR my email address - just one of them.

Let's say I choose to verify my domain, mydomain.com, and I did not verify email. So, when I use AWS-SDK sendEmail(), what email should/can I use given that I did not verify any email?

Can I use any email as long as it is using my domain name? E.g. [email protected]?

Thank you for your answer!

Upvotes: 1

Views: 562

Answers (2)

HSharma
HSharma

Reputation: 82

As long as you are able to verify your domain, yes you can use any email with your domain name. AWS wants to know you are the owner of the domain.

Tip regarding:

"I plan to use AWS-SDK in my EC2 server to talk to SES."

I would recommend to use AWS Lambda function using NodeJS and trigger them from the API gateway. This way you will save money spent on monthly EC2 instances with highly available API to send out emails.

Additionally you can then use this API anywhere in your business process flows.

Here is a sample code to send out emails using AWS SES service via Lambda function.

var AWS = require('aws-sdk');
var ses = new AWS.SES();
 
var RECEIVER = '[email protected]';
var SENDER = '[email protected]';

var response = {
 "isBase64Encoded": false,
 "statusCode": 200,
 "headers": {
        "X-Requested-With": '*',
        "Access-Control-Allow-Headers": 'Content-Type,X-Amz-Date,Authorization,X-Api-Key,x-requested-with',
        "Access-Control-Allow-Origin": '*',
        "Access-Control-Allow-Methods": 'POST,GET,OPTIONS'
    },
 "body": "{\"result\": \"Success.\"}"
 };

exports.handler = function (event, context) {
    var formdata = JSON.parse(event.body);
    sendEmail(formdata, function (err, data) {
        context.done(err, response);
    });
};
 
function sendEmail (formdata, done) {
    var params = {
        Destination: {
            ToAddresses: [
                RECEIVER
            ]
        },
        Message: {
            Body: {
                Text: {
                    Data: 'name: ' + formdata.name + '\nemail: ' + formdata.email + '\ndesc: ' + formdata.desc,
                    Charset: 'UTF-8'
                }
            },
            Subject: {
                Data: 'Website Referral Form: ' + formdata.name,
                Charset: 'UTF-8'
            }
        },
        Source: SENDER
    };
    ses.sendEmail(params, done);
}

Upvotes: 0

Cedomir Rackov
Cedomir Rackov

Reputation: 1092

The verification is there to make sure you are the owner of the domain or at least an email address you want to use.

So when you verify the domain you are verified as the admin of the domain and thus have access to any of the email address on that specific domain.

To elaborate, if you can prove that you can change the DNS records of the domain (as you did for the verification) you can change any email related DNS records such as the MX records (more on the wiki) and thus any additional verification is not necessary.

I encourage you to learn more about the MX records.

Upvotes: 1

Related Questions