2017-10-12 112 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是你想傳遞給玉文件與數據數組