Dreams
Dreams

Reputation: 6122

Nodemailer - Unable to send clickable link

I am using nodemailer for sending emails from my nodejs app. I am successfully able to send an email. But, if I want to send a link, the href or anchor tag is not working. That is the link does not go as part of the mail. The rest of the text is sent. Any ideas?

Here is the relevant code :

var messagebody = "Hello ".concat(req.body.name).concat(", One of your team mates have submitted an application form for intern next summer. Please approve or reject the same on the internship portal. Best Regards.");
var mailOptions = {
            from: from, // sender address
            to: to, // list of receiver
            // cc: cc,
            subject: subject, // Subject line
            text: messagebody, // plaintext body
            html: ' Hello '.concat(req.body.name).concat(' , <br /></br > One of your team mates have submitted an application for intern(s) for next summer. Please approve or reject the proposal on the internship portal. <br /> Here is the link of the internship portal : <a href="https://9.109.124.229:9100/"></a><br /><br /> Best Regards.') // html body
        };

Upvotes: 3

Views: 3780

Answers (2)

Vasileios Pallas
Vasileios Pallas

Reputation: 4877

You can also render a jade (or pug) file and get it as a string

const render = jade.compileFile('./views/my_email.jade');
const html = render(content);

const mailOptions = {
   from: from, // sender address
   to: to, // list of receivers
   subject: subject, // Subject line
   html: html
};

where content is the array with the data you want to pass to the jade file

Upvotes: 1

Sagar
Sagar

Reputation: 1424

Your code is Correct but you havn't wrote anything in between <a></a> tags. Just put some text between them and it will work.

<a href="https://9.109.124.229:9100/"> Click here </a>

Upvotes: 3

Related Questions