Email with amazonSESUnsubscribeUrl not getting delivered

0

Hi Team,

I'm using Amazon SES to send templated emails from my application. I've set up Easy DKIM for my domain and I'm sending emails to a single recipient at a time. However, I'm encountering an issue when I include the {{amazonSESUnsubscribeUrl}} placeholder in my email template.

I'm using SendTemplatedEmailCommand of the Amazon SES SDK to send the email. The ListManagementOptions parameter is included in the command parameters, and it specifies the contact list and topic for the email.

When I send an email without the {{amazonSESUnsubscribeUrl}} placeholder, the email is delivered successfully. However, when I include the {{amazonSESUnsubscribeUrl}} placeholder, the email is not delivered.

In my CloudWatch logs, I'm seeing a RenderingFailure metric for the AWS/SES namespace.

Ashwani
asked 7 months ago476 views
2 Answers
0

Hello. The RenderingFailure metric you're seeing in CloudWatch indicates that Amazon SES encountered an error when trying to render your email template. The error can be due to a variety of reasons, but since you specifically mentioned the inclusion of the {{amazonSESUnsubscribeUrl}} placeholder as the cause, it's a good place to start troubleshooting. Regards, Andrii

profile picture
EXPERT
answered 7 months ago
  • Here's the code snippet of my email service:

    import { SESClient, SendTemplatedEmailCommand } from '@aws-sdk/client-ses';
    
    const params = {
      Destination: {
        ToAddresses: [recipient],
      },
      Source: this.awsOptions.senderEmail,
      Template: template,
      TemplateData: JSON.stringify(data),
      ListManagementOptions: {
        ContactListName: 'TestList',
        TopicName: 'Subscription',
      },
    };
    const command = new SendTemplatedEmailCommand(params);
    await this.sesClient.send(command);
    

    And here's the JSON of my email template:

    {
      "Template": {
        "TemplateName": "TestWelcomeTemplate1",
        "SubjectPart": "Tesr",
        "TextPart": "Dear {{name}} \nToday marks the end of your trial period {{amazonSESUnsubscribeUrl}}",
        "HtmlPart": "<html><p>Dear {{name}} Today marks the end of your trial period</p><a href=\"{{amazonSESUnsubscribeUrl}}\" >unsubscribe here</a ></html>"
      }
    }
    

    Here's the JSON of my topic and contact list:

    {
      "ContactListName": "TestList",
      "Topics": [
        {
          "TopicName": "Subscription",
          "DisplayName": "Subscription Topic",
          "Description": "Unsubcribe from this topic",
          "DefaultSubscriptionStatus": "OPT_IN"
        },
      ],
    }
    

    I've checked the AWS documentation and ensured that I'm using the {{amazonSESUnsubscribeUrl}} placeholder correctly. Furthermore, the ContactListName and TopicName in the ListManagementOptions are set up correctly in my AWS SES setup.

    I would appreciate your assistance in identifying the cause of this

0

Ensure that the Source email (this.awsOptions.senderEmail) is verified in Amazon SES.

Ensure that the recipient email address is either verified (if you're in the Amazon SES sandbox environment) or is a valid email address (if you're in the production environment).

Make sure the template "TestWelcomeTemplate1" has been successfully created in SES and matches the JSON structure you provided.

Ensure that the contact list TestList and topic Subscription are both active and not in a failed or deleted state.

You're adding the unsubscribe URL in both the text and HTML versions of the email. There's nothing inherently wrong with that, but for the sake of debugging, you might want to test by including it in just one part (say, only the HTML version) to see if that makes any difference.

Occasionally, the manner in which the placeholders are positioned can cause issues. Although your placement seems correct, for debugging purposes, try to reduce any unnecessary whitespace or newline characters around the {{amazonSESUnsubscribeUrl}} placeholder.

Although it seems unrelated, sometimes the permissions of the IAM role/user might prevent certain functionalities. Ensure that the role/user has permissions to ses:SendTemplatedEmail, access to the specified contact list, and the topic.

Regards, Andrii

profile picture
EXPERT
answered 7 months ago
  • Thanks Andril,

    As I mentioned the email is delivered when I remove {{amazonSESUnsubscribeUrl}} placeholder, so this almost clear the 1st, 2nd & 3rd point.

    4th Point - I have verified this one.

    5th & 6th Point - Triggered email again after updating the template:

    { "Template": { "TemplateName": "TestWelcomeTemplate1", "SubjectPart": "Tesr", "TextPart": "Dear {{name}} Today marks the end of your trial period ", "HtmlPart": "<html><p>Dear {{name}} Today marks the end of your trial period {{amazonSESUnsubscribeUrl}}</p></html>" } }

    7th Point: I'm the one who created the contact list and the topic.

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