【问题标题】:how to run nodemailer on MongoDB Realm? nodemailer failed to execute on MongoDB Realm如何在 MongoDB 领域运行 nodemailer? nodemailer 无法在 MongoDB Realm 上执行
【发布时间】:2022-01-13 12:19:08
【问题描述】:

如何在 MongoDB Realm 上运行 nodemailer? nodemailer 无法在 MongoDB Realm 上执行

代码:

    const nodemailer = require("nodemailer");

exports = async function (changeEvent) {
  try {
    const transporter = nodemailer.createTransport({
      service: "gmail",
      auth: {
        user: "somthing@gmail.com",
        pass: "passw0rd",
      },
    });

    let info = transporter.sendMail({
      from: "something@gmail.com",
      to: "wdcjdwzcvpbagtd@frederictonlawyer.com",
      subject: "YesterDay Report Details!",
      html: `
<div style=" text-align: center;" >
    style=" width: 100%; height: 100px; margin-top: 10px;" />
    <br />
    <hr />
    <br />
    <p>
    <span style=" color: rgb(99, 99, 99); font-weight: bold;">
    adminMail </span>, hi there!
     </p>
    
    <br />    
    
    <p style="margin-top: 20px; color: gray;">
    This link expire in 10 minutes</p>
    
    <h5>Total Income Aomunt   : </h5>
    <h5>Avrage Income Aomunt  : </h5>
    <h5>Patientions Count     : </h5>
    <h5>Over-reported Disease : </h5>
    <h5>Reported All Disease  : </h5>
    
    <p>Thanks and Regards</p>
    
    <div style="margin-top: 50px;">&copy; 2021 Apollo</div>
  </div>
`,
    });

    if (info) {
      console.log(info);
    }

    console.log(
      `Successfully send daily report Mail to wdcjdwzcvpbagtd@frederictonlawyer.com :)`
    );
  } catch (err) {
    console.error("Failed to run the function : ", err);
  }
};

输出:

运行于 2022 年 1 月 13 日星期四 17:33:04 GMT+0530(印度标准时间) 错误: 无法执行“node_modules/nodemailer/lib/nodemailer.js”的源代码:FunctionError:无法执行“node_modules/nodemailer/lib/mailer/index.js”的源代码:FunctionError:无法执行“node_modules/nodemailer/”的源代码lib/shared/index.js': TypeError: 'networkInterfaces' 不是函数 在 node_modules/nodemailer/lib/shared/index.js:41:80(63)

at require (native)
at node_modules/nodemailer/lib/mailer/index.js:37:22(39)

at require (native)
at node_modules/nodemailer/lib/nodemailer.js:13:22(13)

运行于 2022 年 1 月 13 日星期四 17:33:17 GMT+0530(印度标准时间) 错误: 无法执行“node_modules/nodemailer/lib/nodemailer.js”的源代码:FunctionError:无法执行“node_modules/nodemailer/lib/mailer/index.js”的源代码:FunctionError:无法执行“node_modules/nodemailer/”的源代码lib/shared/index.js': TypeError: 'networkInterfaces' 不是函数 在 node_modules/nodemailer/lib/shared/index.js:41:80(63)

at require (native)
at node_modules/nodemailer/lib/mailer/index.js:37:22(39)

at require (native)
at node_modules/nodemailer/lib/nodemailer.js:13:22(13)

但它在我的系统上工作......

【问题讨论】:

  • 你能看到web UI上的依赖关系
  • 只是 nodemailer
  • nodemailer@6.4.10 支持 MonogoDB 领域。一些旧版本的节点邮件程序正在使用 mongoDB Realm... Dev Post Linkdev.to/jacksonkasi/…

标签: javascript node.js mongodb nodemailer mongodb-realm


【解决方案1】:

您需要添加 nodemailer 作为依赖项

Functions 屏幕中,您将看到dependencies 选项卡。单击它并按照说明将nodemailer 添加为依赖项。

【讨论】:

  • 先生,我已经添加了依赖项 "nodemailer" 。但仍然是同样的错误
猜你喜欢
  • 2023-03-29
  • 2014-10-30
  • 2019-07-18
  • 2022-01-17
  • 2023-02-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-01-09
相关资源
最近更新 更多