2

I want to write html email with node.js app. Email is sent successfully. When I log text, it shows me something like this

<html><body><h1>Hi John!</h1><p>Jack just shared graph with you</p><p><a href='https://some.url.here/blablabla'>View here</a></p></body></html>

When I open this email with google inbox, it shows me html well, but a tag have no href attribute, so I cant go to given url from email. I am using sparkpost for email.

Can anyone tell me why it happens ?

Gor
  • 2,808
  • 6
  • 25
  • 46
  • I am actually having the same issue, using templates in Sparkpost. Gmail is filtering out the HREF completely. Only when it is just an url, like `www.happycampers.com` without the protocol and no querystring, does the href remain. Bit disturbing. When I send with Mandrill it worked fine, with having mandrill's click tracking link in the href. – Mattijs Apr 10 '16 at 03:50
  • Just found out it is good to sometimes read the Docs :). Apparently when you substitute the whole URL in an HREF, you need to use 3 curlies. – Mattijs Apr 10 '16 at 04:04

1 Answers1

5

You might want to try using double quotes for your href. I was able to get it to work using the code sample from developers.sparkpost.com

var key = '<YOUR API KEY>'
, SparkPost = require('sparkpost')
, sparky = new SparkPost(key);

sparky.transmissions.send({
  transmissionBody: {
    content: {
      from: 'testing@sparkpostbox.com',
      subject: 'Oh hey!',
      html:'<html><body><h1>Hi John!</h1><p>Jack just shared graph with you</p><p><a href="https://some.url.here/blablabla">View here</a></p></body></html>'
    },
    recipients: [
      {address: 'developers+stackoverflow@sparkpost.com'}
    ]
  }
}, function(err, res) {
  if (err) {
    console.log('Whoops! Something went wrong');
    console.log(err);
  } else {
    console.log('Woohoo! You just sent your first mailing!');
  }
});
Aydrian Howard
  • 379
  • 1
  • 8