Use Nodejs's nodemailer to send mail routines via 163 mailboxes

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.