First you need to install Nodemailer
#nmp Nodemailer Install--save
Then just rewrite the example of the official document, the code is as follows:
' Use strict '; Const Nodemailer= Require (' Nodemailer ');//Generate Test SMTP service account from Ethereal.email//Only needed if you don't have a real mail account for testingNodemailer.createtestaccount (err, account) = { //Create reusable Transporter object using the default SMTP transportLet transporter =Nodemailer.createtransport ({host:' Smtp.163.com ', Port:465, Secure:true,//true for 465, false to other portsAuth: {User:' [email protected] ',//generated ethereal userPass: ' PASSWORD '//generated ethereal password } }); //Setup email data with Unicode symbolsLet mailoptions ={from:' [email protected] ',//Sender AddressTo: ' [email protected],[email protected] ',//List of receiversSubject: ' Title: This is an email sent from Nodejs ',//Subject LineText: ' How are you? ',//Plain Text BodyHTML: ' <b> Beijing welcomes you </b> '//HTML Body }; //send mail with defined transport objectTransporter.sendmail (mailoptions, (error, info) = { if(Error) {returnConsole.log (Error); } console.log (' Message Sent:%s ', Info.messageid); //Preview only available when sending through a Ethereal accountConsole.log (' Preview URL:%s '), Nodemailer.gettestmessageurl (info)); //Message Sent: <[email protected]> //Preview url:https://ethereal.email/message/waqkmgkddxqdoou ... });});
Repeat: Nodemailer's official website in https://nodemailer.com/about/, generally see the original text than net text.
Use Nodejs's nodemailer to send mail routines via 163 mailboxes