how to run nodemailer on MongoDB Realm? nodemailer failed to execute on MongoDB Realm

Viewed 121

how to run nodemailer on MongoDB Realm? nodemailer failed to execute on MongoDB Realm

code:

    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);
  }
};

output:

enter image description here

ran at Thu Jan 13 2022 17:33:04 GMT+0530 (India Standard Time) error: failed to execute source for 'node_modules/nodemailer/lib/nodemailer.js': FunctionError: failed to execute source for 'node_modules/nodemailer/lib/mailer/index.js': FunctionError: failed to execute source for 'node_modules/nodemailer/lib/shared/index.js': TypeError: 'networkInterfaces' is not a function at 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)

ran at Thu Jan 13 2022 17:33:17 GMT+0530 (India Standard Time) error: failed to execute source for 'node_modules/nodemailer/lib/nodemailer.js': FunctionError: failed to execute source for 'node_modules/nodemailer/lib/mailer/index.js': FunctionError: failed to execute source for 'node_modules/nodemailer/lib/shared/index.js': TypeError: 'networkInterfaces' is not a function at 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)

but it's work on my system...

enter image description here

enter image description here

1 Answers

You will need to add nodemailer as a dependency

In the Functions screen, you will see a dependencies tab. Click on it and follow the instructions to add nodemailer as a dependency.

Functions Screen

Related