rafaelcb21 rafaelcb21 - 1 year ago 139
Node.js Question

Sendgrid change href of link

I am using Nodejs with Express and I am sending an email through Sendgrid, but Sendgrid is changing the href link

var emailText = '<!DOCTYPE html><html><head><meta charset="UTF-8"></head><body><a href="https://www.google.com">Here</a></body></html>'
var from_email = new helper.Email('[email protected]');
var to_email = new helper.Email('[email protected]');
var subject = 'Test';
var content = new helper.Content("text/html", emailText)
var mail = new helper.Mail(from_email, subject, to_email, content);
var request = sg.emptyRequest({
method: 'POST',
path: '/v3/mail/send',
body: mail.toJSON(),
sg.API(request, function(error, response) {
if (error) {
console.log('Error response received');

When the email arrives the following link appears:


Could someone help me solve this problem?

Answer Source

I believe this is caused by the URL click-tracking feature of sendgrid. It will redirect to your intended resource, but does not look pretty. You can turn it off in sendgrid, but it will disable URL tracking on all emails sent by that account. If you are integrating with a 3rd-party link-tracker such as bit.ly or have your GA on lock-down, this may not bother you.

Here's more information on the feature in sendgrid: https://sendgrid.com/docs/User_Guide/Settings/tracking.html

Turn that off and see how your emails look.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download