Gor
Gor

Reputation: 2908

HTML email a tag

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 ?

Upvotes: 2

Views: 287

Answers (1)

Aydrian Howard
Aydrian Howard

Reputation: 389

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: '[email protected]',
      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: '[email protected]'}
    ]
  }
}, function(err, res) {
  if (err) {
    console.log('Whoops! Something went wrong');
    console.log(err);
  } else {
    console.log('Woohoo! You just sent your first mailing!');
  }
});

Upvotes: 5

Related Questions