Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SES on node.js not sending the email although it return 'success' response

I tried sending an email using SES. The to address is same as the from address, and is verified in AWS SES.

        usersList = [{
            "Destination": {
                "ToAddresses": [
                    "[email protected]"
                ]
            },
            "ReplacementTemplateData": `{ "name":"User1", "message": "Hell no" }`
        }];
        defaultTemplateData = `{ "name":"Student", "message": ` + req.body.message + ` }`;

        var params = {
            Destinations: usersList,
            Source: "[email protected]", /* required */
            Template: `SomeTemplate`, /* required */
            DefaultTemplateData: defaultTemplateData
        };
        // Create the promise and SES service object
        var sendPromise = ses.sendBulkTemplatedEmail(params).promise();

        // Handle promise's fulfilled/rejected states
        return sendPromise.then(
            function (data) {
                console.log('sent successfully');
                console.log(data);
                return data;
            }).catch(
            function (err) {
                console.log('error happened off');
                console.error(err, err.stack);
                return err;
            });
    }

I'm getting a successful response to this code.

{ ResponseMetadata: { RequestId: '14ada23f-someID-5be700be687f' }, Status: [ { Status: 'Success', MessageId: '010001619e8a79ed-someID-000000' } ] }

But the email is not being delivered.

like image 984
Flyn Sequeira Avatar asked Mar 07 '23 21:03

Flyn Sequeira


1 Answers

From what I figured out, the email returns success although it didn't send when the template you created doesn't match the dataset yours sending. Maybe the template has a variable that isn't being addressed by the dataset you give it.

The return value will still be a success which it shouldn't. Upon fixing that bit, I started to receive emails. SES emails don't go to the junk too easily.

like image 95
Flyn Sequeira Avatar answered Apr 04 '23 09:04

Flyn Sequeira