nodemailer:连接意外关闭

nodemailer: Connection closed unexpectedly

我向 firebase 部署了一个函数,当我测试发送电子邮件的函数时,我收到以下错误:

Error: Connection closed unexpectedly
    at SMTPConnection._onClose (/workspace/node_modules/nodemailer/lib/smtp-connection/index.js:824:34)
    at TLSSocket.SMTPConnection._onSocketClose (/workspace/node_modules/nodemailer/lib/smtp-connection/index.js:191:42)
    at Object.onceWrapper (events.js:520:26)
    at TLSSocket.emit (events.js:412:35)
    at TLSSocket.emit (domain.js:537:15)
    at net.js:686:12
    at TCP.done (_tls_wrap.js:564:7)
    at TCP.callbackTrampoline (internal/async_hooks.js:130:17) 

这是我用来发送邮件的函数:

const transporter = nodemailer.createTransport({
  host: "host",
  port: 465,
  secure: true,
  auth: {
    user: "email",
    pass: "pass",
  },
});

exports.sendMailUser =
  functions.firestore.document("collection/Users").onUpdate(async (snapshot, context) => {
    const data = snapshot.after.data();
    const dataReceived = data.users;
    const name = dataReceived[dataReceived.length - 1].name;
    const email = dataReceived[dataReceived.length - 1].email;
    const password = dataReceived[dataReceived.length - 1].password;
    const body = "As dori crearea unui cont pe portalul e-Radauti cu urmatoarele date: <br>" + name + "<br>" + email + "<br>" + "password" + password;
    const mailOptions = {
      from: "Adaugare User pe portal-ul e-Radauti",
      to: "mail",
      subject: "Adaugare user pe portalul e-Radauti",
      bcc: "bcc",
      html: body,
    };
    console.log(mailOptions);
    await transporter.sendMail(mailOptions);
    return null;
  });

编辑: 我已经根据@Dharmaraj 的建议更新了代码,而且我还有 Blaze(随用随付)计划

我已经通过创建一个新的传输器解决了这个问题,并将其添加到函数中:

exports.sendMailUser =
  functions.firestore.document("collection/Users").onUpdate(async (snapshot, context) => {
    const transporter2 = nodemailer.createTransport({
      host: host,
      port: 465,
      debug: true,
      secure: true, 
      auth: {
        user: user,
        pass: pass,
      },
    });
    var data = snapshot.after.data();
    var dataReceived = data.users;
    var body = "As dori crearea unui cont pe portalul e-Radauti cu urmatoarele date: <br>" + dataReceived[dataReceived.length - 1].name + "<br>" + dataReceived[dataReceived.length - 1].email + "<br>" + "password:" + dataReceived[dataReceived.length - 1].password;
    var mailOptions = {
      from: "Adaugare User pe portal-ul e-Radauti",
      to: to,
      subject: "Adaugare user pe portalul e-Radauti",
      bcc: bcc,
      html: body,
    };
    //console.log(mailOptions);
    await transporter2.sendMail(mailOptions);
    return null;
  });