Node.js nodemailer Gmail SMTP not working

133
August 29, 2021, at 02:50 AM

require("dotenv").config();
"use strict";
var nodemailer = require("nodemailer");
const SMTPTransport = require("nodemailer/lib/smtp-transport");
console.log("Nach attr");
// async..await is not allowed in global scope, must use a wrapper
async function main() {
  // Generate test SMTP service account from ethereal.email
  // create reusable transporter object using the default SMTP transport
  console.log("vor transporter");
  
  
  let transporter = nodemailer.createTransport({
    host: "smtp.gmail.com",
    port: 465,
    secureConnection: true, // true for 465, false for other ports
    auth: {
      user: 'email', // generated ethereal user
      pass: 'password', // generated ethereal password
      tls: {
        rejectUnauthorized: false
      }
    },
  });
  transporter.verify().then(console.log).catch(console.error);
  
  let mailOptions = {
    from: 'testsender',
    to: 'reciever',
    subject: 'Test Mail',
    text: '123456789'
  };
  console.log("vor transporter.send");
  transporter.sendMail(mailOptions, function (err, data) {
    if (err) {
      console.log('Error Occurs: ', err);
    } else {
      console.log('Email sent!');
    }
  });
  //console.log("Message sent: %s", info.messageId);
  // Message sent: <b658f8ca-6296-ccf4-8306-87d57a0b4321@example.com>
  // 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);

Console output

Error Occurs:  Error: connect ETIMEDOUT 64.233.166.108:465
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1141:16) {
  errno: 'ETIMEDOUT',
  code: 'ESOCKET', 
  syscall: 'connect',
  address: '64.233.166.108',
  port: 465,
  command: 'CONN'
}
Rent Charter Buses Company
READ ALSO
Change type / len of a user defined column in My SQL Workbench

Change type / len of a user defined column in My SQL Workbench

I am using a MySQL query in Workbench that uses group_concat() to group multiple string values

111
Is there a way to bypass anonymising service check?

Is there a way to bypass anonymising service check?

I have been dabbling with python and selenium for a while nowI Was trying to work with a website, and as I realize that I may have to make multiple calls to the site, and to avoid any ip related issue, I tried to use proxy

110
Adding swatches to a mail template without using a layout

Adding swatches to a mail template without using a layout

I am working on a mail template and I would like to ask if it's possible to add the colour swatches functionality to aphtml

130
How do i add functionality to my nav dots in my image slider?

How do i add functionality to my nav dots in my image slider?

Currently my nav dots do not have any functionalityHow do i add that

51