Paul Gregson
Paul Gregson

Reputation: 166

Amazon SES - Can't get email to be delivered

I have an aws ubuntu server running a node.js application. I am trying to build a simple forgot password feature which sends users email. The code runs but no email is delivered, so I assume I am still missing something.

1) Within SES I verified the email domain a2zcribbage.com. I assume this means I can now send email from any alias under this domain, right?

2) I npm installed the SES module onto my ec2 server.

3) My code looks as follows:

aws.config.update({accessKeyId: 'MYKEY', secretAccessKey: 'MYKEY', region: 'us-west-2'});
var ses = new aws.SES({apiVersion: '2010-12-01'}); // load AWS SES
var to = [post.email]; // send to list
var from = '[email protected]'; // this must relate to a verified SES account
ses.sendEmail( { // this sends the email @todo - add HTML version
      Source: from, 
      Destination: { ToAddresses: to },
      Message: {
        Subject: { Data: 'a2zCribbage - Temporary Password' },
        Body: {
          Text: {
            Data: "Your username is: " + userName + ". Your temporary password is: " + tempPassword
          }
        }
      }
    }, function(err, data) { if (err) console.log(err); });

The code runs without error, but no email is delivered. How do I debug this further given there's no error?

Upvotes: 0

Views: 268

Answers (2)

Paul Gregson
Paul Gregson

Reputation: 166

I'll answer my own question here. Good feedback from everyone. The one thing I was missing is that by default, when you create an SES account, you are put into a "sandbox" mode, and not a full fledged email sending mode, so I was trying to send emails and it wasn't allowing it. Once I requested I be taken out of sandbox mode everything worked just fine.

Upvotes: 0

BMW
BMW

Reputation: 45243

My suggestion for your issue:

  1. Make sure you have been removed from sandbox, to do that, you need contact aws to extend the limits, that's free service for any aws accounts.

  2. register a real mailbox directly to SES, for example, [email protected] to test if the code works or not.

  3. From the code, seems you missed to load aws sdk.

    var aws = require('aws-sdk');

  4. create a SNS task, subscript a SMS or mailbox, enable bounced or complain notification in SES, with it, you can confirm if the setting is proper or not.

let me know if this can help you to fix your issue.

Upvotes: 1

Related Questions