sinusGob
sinusGob

Reputation: 4303

Nodemailer, customized email html template with CSS

Im trying to add some css style to my email template but seems like when it shows in the inbox of the user, seems like the css is off.

function email() {

  var html = '<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">'
  html += 'Hello,<br> Hey click on the link to verify your email.<br>';
  html += "<a type='button' class='btn btn-primary btn-lg' href='http://localhost:3000/hello'";

  return html;

}

Email code

   var transporter = nodemailer.createTransport(smtpTransport({
  service: 'gmail',
  host : 'smtp.gmail.com',
  secureConnection : true,
  auth : {
    user: 'auth',
    pass: 'abc123'
  }
}));


mailOptions = {
  to : 'user',
  subject : "Please confirm your Email account",
  html : email()
}

transporter.sendMail(mailOptions, function(error, response) {
  if(error){
    console.log(error);

  }else{
    console.log("Message sent: " + response);

  }
});

The css is not shown, did i do anything wrong?

Upvotes: 1

Views: 1781

Answers (1)

Nathan
Nathan

Reputation: 39

you cannot send or pass pure css class's in email you need to use an inline package, or inlining your css

Upvotes: 2

Related Questions