MessageID from SendEmail doesn't always match delivery notification

0

During my testing, I have been using the MessageId returned from AmazonSimpleEmailServiceClient::SendEmailAsync as my primary key in my database so I can keep tabs on bounces, complaints, and deliveries for each message sent.

Everything seemed to be working as expected when sending out batches to my 5 test emails during development, however, when I increased my recipients to 30 I noticed some of them never got the delivery notification (but they received the email).

I added logging to my delivery notification lambda and found that sometimes the Mail.MessageId doesn't match any ID's that I have stored in my database. Hence why It looked like I wasn't getting delivery notifications on some recipients.

Any idea why I might be seeing this? I recently made some changes to my DNS to accept receives +MailFrom domain so not sure if that did something funny but everything else seems to be working as expected.

I'm using dotnet core
AWSSDK.SimpleEmail 3.3.101.131
Amazon.Lambda.SQSEvents 1.1.0
Amazon.Lambda.Core 1.1.0

//Sending
var sendEmailResponse = await m_emailClient.SendEmailAsync(email);
recipient.MessageId = sendEmailResponse.MessageId;
//Update to db happens in bulk after the send loop
//Delivery notification
private void ProcessDeliveryEvent(SQSEvent.SQSMessage message)
{
    var notification = JsonConvert.DeserializeObject<AmazonSqsNotification>(message.Body);
    var delivery = JsonConvert.DeserializeObject<AmazonSesDeliveryNotification> (notification.Message);
    UpdateEmailStatusInDatabse(delivery.Mail.MessageId, "Delivered");
}
Jake38
asked 4 years ago329 views
1 Answer
0

I was able to resolve this by using raw messages. I included my custom message id when sending raw messages. I then set "Include Original Headers" in my ses notification settings, which allows me to parse the headers in my notification lambdas and extract the desired messageid.

Edited by: Jake38 on Apr 28, 2020 2:34 PM

Jake38
answered 4 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions