Sendgrid-nodejs: Unsubscribe links in dynamic template are plain text

Created on 28 Apr 2020  Â·  6Comments  Â·  Source: sendgrid/sendgrid-nodejs

Issue Summary

I m using SG's dynamic template feature to send transactional emails in Node/Express. Everything works fin except that instead of including working links, the footer simply prints "Unsubscribe - Unsubscribe Preferences" as plain text which is not clickable.

I have attempted to use Subscription Tracking, which provides a working link for global unsubscribes, but does not allow me to us the subscription groups I set up.

Here is my code for sending mail:

if (process.env.NODE_ENV === 'production') {
    for (let i = 0; i < recipients.length; i++) {
      const msg = {
        from: "[email protected]",
        template_id: process.env.SENDGRID_NEW_POST,
        personalizations: [{
            to: { email: recipients[i].email },
            dynamic_template_data: {
                subject: "New Post: " + poster.username + " just posted something",
                recipient_name: recipients[i].username, 
                poster_name: poster.username,
                group_name: group.name,
                post_text: newPost.post.body,
                button_url: process.env.VUE_HOME_URL,
            },
        }],

      };
      let sendResult = sgMail.send(msg);
    }
  }

Technical details:

  • sendgrid-nodejs version: 6.4.0
  • node version: 10.15.0
question

Most helpful comment

I'm not seeing a group ID in your message. Can you try adding the unsubscribe group ID? Example:

const msg {
    ...
    asm: {
        groupId: 12345
    },
    ...
};

All 6 comments

I'm not seeing a group ID in your message. Can you try adding the unsubscribe group ID? Example:

const msg {
    ...
    asm: {
        groupId: 12345
    },
    ...
};

Ok that works. Thanks very much. Is that somewhere in the documentation that I simply missed?

There's a little info about the asm param here: https://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/index.html

Ok. I am surprised you don't get more questions about that. Maybe I am the
only one though. Thanks for your help.

On Fri, May 1, 2020 at 10:51 AM childish-sambino notifications@github.com
wrote:

There's a little info about the asm param here:
https://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/index.html

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/sendgrid/sendgrid-nodejs/issues/1107#issuecomment-622419152,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAJTY42NRPYKRDP5OJZXDI3RPLOX7ANCNFSM4MST32MQ
.

Just to clarify... what is the secret?

I've added

asm: {
        groupId: 12345
    },

into the msg object, but I'm getting the same behavior as OP- it adds un-stylable links to the bottom of my email when really I would like them to be centered and have a different background color.

@childish-sambino is this possible?

actually now that I read it again it seems that OP hd a different issue. His "Unsubscribe" text is not clickable whereas mine is...

Was this page helpful?
0 / 5 - 0 ratings

Related issues

agostonbonomi picture agostonbonomi  Â·  3Comments

thidasapankaja picture thidasapankaja  Â·  4Comments

thinkingserious picture thinkingserious  Â·  4Comments

Loriot-n picture Loriot-n  Â·  4Comments

Chrischuck picture Chrischuck  Â·  3Comments