简体   繁体   中英

How to send personalized emails using sendBulkEmail on amazon ses?

I have everything for my SES setup and all the requests are working. What I am trying to do now is send personalized bulk emails using replacementData. So, if there are two recepients jane@doe.com and johnny@doe.com I want to replace their respective names in the template. So that Jane gets an email saying "Hi Jane" and johnny gets: "Hi Johnny". I understand that I can do this using the JSON data but I am implementing it on NodeJS and would like to use the AWS SDK as much as possible. The code that I am currently using:

var params = {
    BulkEmailEntries: [ /* required */ {
            Destination: { /* required */
                BccAddresses: [],
                CcAddresses: [],
                ToAddresses: ['jane@gmail.com', 'john@gmail.com']
            },
            ReplacementEmailContent: {
                ReplacementTemplate: {
                    ReplacementTemplateData: `{"name":"Jane"},{"name":"John}`
                }
            },
            ReplacementTags: [{
                    Name: 'Test',
                    /* required */
                    Value: 'test' /* required */
                },
                /* more items */
            ]
        },
        /* more items */
    ],
    DefaultContent: { /* required */
        Template: {
            TemplateData: '{"name":"unknown"}',
            TemplateName: 'testTemplate2'
        }
    },
    DefaultEmailTags: [{
            Name: 'test',
            /* required */
            Value: 'Test' /* required */
        },
        /* more items */
    ],
    FromEmailAddress: 'info@xyz.com',
    ReplyToAddresses: []
};

The email is sent but in both of them it say "Hi Jane". Please help

Can you please check if the emails are send as different mails, like no other recipients in the mail. I believe there must be two destinations because you have used two values in ReplacementTemplateData. There is only one destination and two replacement data. So it is taking first replacement for both emails. I believe that's the issue. Please confirm.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM