nodemailer使用_如何使用Nodemailer使用HTML作为内容发送电子邮件 Node.js
nodemailer使用
Prerequisite:
先決條件:
How to send emails using Nodemailer | Node.js
如何使用Nodemailer發(fā)送電子郵件。 Node.js
How to send emails with attachments using Nodemailer | Node.js
如何使用Nodemailer發(fā)送帶有附件的電子郵件。 Node.js
This time around, we will see how to compose or build/format our email body using HTML?
這次,我們將看到如何使用HTML編寫或構(gòu)建/格式化電子郵件正文?
Code:
碼:
// load the node mailer module var nodemailer = require('nodemailer'); //configure the transportervar transporter = nodemailer.createTransport({ service: 'gmail',auth: {user: '[email?protected]',pass: 'your gmail password'} });//email optionsvar mailOptions = {from: '[email?protected]',to: '[email?protected]',subject: 'Sending Email using Node.js',html: '<h1> Node JS </h1> <br> <h5> Hello World</h5>' };transporter.sendMail(mailOptions, function(error, info){if (error) {console.log(error);} else {console.log('Email sent');} });Note: You can use the same format and send as many attachments as possible. Make sure the closing curly bracket of each attachment is separated by a comma sign (,).
注意:您可以使用相同的格式并發(fā)送盡可能多的附件。 確保每個(gè)附件的大括號(hào)用逗號(hào)(,)分隔。
Finally, start your node app and if sending is successful, the phrase ‘email sent' will be printed out on the console or terminal.
最后,啟動(dòng)您的節(jié)點(diǎn)應(yīng)用程序,如果發(fā)送成功,則將在控制臺(tái)或終端上打印出短語(yǔ)“已發(fā)送電子郵件”。
Check you're the email's inbox.
檢查您是否是電子郵件的收件箱。
Using Gmail as your transporter, you can also enable the less secure app access setting.
使用Gmail作為傳輸者,您還可以啟用安全性較低的應(yīng)用訪問(wèn)設(shè)置。
Sending email requires internet connection.
發(fā)送電子郵件需要互聯(lián)網(wǎng)連接。
Do not fear about your password security. It's a tested and secured module used by many since 2010.
不要擔(dān)心您的密碼安全性。 自2010年以來(lái),它已被許多人使用并經(jīng)過(guò)測(cè)試和保護(hù)。
Thanks for coding with me! See you @ the next article. Feel free to drop a comment or question.
感謝您與我編碼! 下次見。 隨意發(fā)表評(píng)論或問(wèn)題。
翻譯自: https://www.includehelp.com/node-js/how-to-send-emails-with-nodemailer-using-html-as-content-node-js.aspx
nodemailer使用
總結(jié)
以上是生活随笔為你收集整理的nodemailer使用_如何使用Nodemailer使用HTML作为内容发送电子邮件 Node.js的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: Java ObjectOutputStr
- 下一篇: c# uri.host_C#| Uri.