2017-10-12 143 views
2

我正在使用nodemailer从我的nodejs应用程序发送电子邮件。我成功地能够发送电子邮件。但是,如果我想发送链接,则href或定位标记不起作用。这是链接不作为邮件的一部分。其余的文本被发送。有任何想法吗?Nodemailer - 无法发送可点击链接

下面是相关代码:

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 
     }; 

回答

2

你的代码是正确的,但你没有带在<a></a>标签之间写任何东西。 只需在它们之间放置一些文本,它就可以工作。

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

我可以发送它,否则,带有换行符的文本(以及我尝试加粗的字符串)会按需要发送。但是,链接不显示。 – Tarun

+1

更改此行Click here Sagar

1

您也可以呈现玉(或哈巴狗)文件,并把它作为一个字符串

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 
}; 

其中content是你想传递给玉文件与数据数组