Home > database >  nodemailer timing out when trying to send email
nodemailer timing out when trying to send email

Time:10-27

I have this:

app.post('/sendSessionConformationEmail', (req, res) => {
        if (!req.session.loggedin) {
        res.redirect('/login')
        req.session.destroy()
        }
            var email = req.body.email;
            var name = req.body.name;
            var trainername = req.body.trainername;
            var sessionDate = new Date().toLocaleString();
            console.log(email)
            console.log(name)
            console.log(trainername)
            console.log(sessionDate)

            // async..await is not allowed in global scope, must use a wrapper
            async function main() {
            // Generate test SMTP service account from ethereal.email
            // Only needed if you don't have a real mail account for testing
            let testAccount = await nodemailer.createTestAccount();

            // create reusable transporter object using the default SMTP transport
            let transporter = nodemailer.createTransport({
                host: "smtp.gmail.com",
                port: 587,
                secure: false, // true for 465, false for other ports
                auth: {
                    user: "[email protected]",
                    pass: "myauthpassword",
                },
                tls:{
                    rejectUnauthorized:false
                }
            });

            // send mail with defined transport object
            let info = await transporter.sendMail({
                from: '[email protected]', // sender address
                to: "[email protected]", // list of receivers
                subject: "Hello ✔", // Subject line
                text: "Hello world?", // plain text body
            });

            console.log("Message sent: %s", info.messageId);
            // Message sent: <[email protected]>

            // Preview only available when sending through an Ethereal account
            console.log("Preview URL: %s", nodemailer.getTestMessageUrl(info));
            // Preview URL: https://ethereal.email/message/WaQKMgKddxQDoou...
            }

            main().catch(console.error);
    })

I copied the code straight from the nodemailer website, and made the necessary changes. However, when I run this code, nothing sends, and it actually gives me this error:

 Error: connect ETIMEDOUT 13.49.22.0:443
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1146:16) {
  errno: -60,
  code: 'ETIMEDOUT',
  syscall: 'connect',
  address: '13.49.22.0',
  port: 443,
  type: 'FETCH',
  sourceUrl: 'https://api.nodemailer.com/user'
}

I've been using nodemailer with this code for over 2 years, never gotten this error, and it is killing me. Is anyone able to help?

CodePudding user response:

you should allow third party apps use your gmail. https://support.google.com/accounts/answer/3466521?hl=en

CodePudding user response:

ethereal.email (13.49.22.0) is down today. Runs on AWS.

  • Related