/ scripts / verifyEtherealSmtp.js
verifyEtherealSmtp.js
 1  const nodemailer = require("nodemailer")
 2  
 3  const options = {
 4    port: 587,
 5    host: "smtp.ethereal.email",
 6    secure: false,
 7    auth: {
 8      user: "irma.stehr61@ethereal.email",
 9      pass: "qrpvnHWBqPEKPfFytS",
10    },
11  }
12  
13  const transporter = nodemailer.createTransport(options)
14  transporter.verify(function (error) {
15    if (error) {
16      console.log(error)
17    } else {
18      console.log("Ethereal server is ready to take our messages")
19    }
20  })
21  
22  const message = {
23    from: "from@example.com",
24    to: "to@example.com",
25    subject: "Did this email arrive?",
26    html: "Hello World!",
27  }
28  
29  transporter.sendMail(message).then(response => {
30    console.log("Test email URL: " + nodemailer.getTestMessageUrl(response))
31  })