nodemailer



  • I'm trying to send an email, and install the nodemailer, but I get this error when I run, help !.

    Error while executing user script. Unable to find module nodemailer
    Searched paths: 
    nodemailer
    /app/nodemailer
    . 
    
      77 | 
      78 |  function afterRender(req, res, done) {
    > 79 |     var mailer = require('nodemailer');
         |                  ^
      80 | 
      81 |     var smtpTransport = mailer.createTransport('smtps://user%40gmail.com:pass@smtp.gmail.com');
      82 | 
    
    
    Error: Unable to find module nodemailer
    Searched paths: 
    nodemailer
    /app/nodemailer
    
        at doRequire (/app/node_modules/jsreport-core/lib/render/safeSandbox.js:232:11)
        at _require (/app/node_modules/jsreport-core/lib/render/safeSandbox.js:72:14)
        at Object.apply (/app/node_modules/vm2/lib/contextify.js:288:34)
        at Object.afterRender (evaluate-user-script.js:79:18)
        at __runAfter (/app/node_modules/jsreport-scripts/lib/scriptEvalChild.js:120:26)
        at Object.apply (/app/node_modules/vm2/lib/contextify.js:288:34)
        at evaluate-user-script.js:110:1
        at ContextifyScript.Script.runInContext (vm.js:59:29)
        at VM.run (/app/node_modules/vm2/lib/main.js:212:72)
        at run (/app/node_modules/jsreport-core/lib/render/safeSandbox.js:183:19)
    
    

  • administrators

    hi! you need to enable the module in the configuration in order to use it, it is mentioned here , if you have done this already, please share the configuration that you are using.



  • is configured with this code

    {
       "extensions": {
         "scripts": {
           "allowedModules": ["request"]
         }
       }
    }



  • the same thing keeps coming


  • administrators

    you need to update the config with

    {
       "extensions": {
         "scripts": {
           "allowedModules": ["request", "nodemailer"]
         }
       }
    }
    


  • Again error is coming out, I'm using this code to send mail, okay?

    ´´´
    function afterRender(req, res, done) {
    var mailer = require('nodemailer');

    var smtpTransport = mailer.createTransport('smtps://user%40gmail.com:pass@smtp.gmail.com');
    
    var mail = {
        from: "Jan Blaha <malca.kike.9@gmail.com>",
        to: "marlon.50294@gmail.com",
        subject: "Sending email from node.js",
        text: "See the attached report",
        html: "<b>See the attached report</b>",
        attachments: [
        {  
            filename: 'Report.pdf',
            content: new Buffer(res.content)
        }],
    }
    
    smtpTransport.sendMail(mail, function(error, response){
        smtpTransport.close();
        if(error){
            return done(error);
        }
    
        return done();
    });
    

    }
    ´´´


  • administrators

    i guess that you have different error message than the Unable to find module nodemailer, right?

    the code looks good, however res.content should be a Buffer already, so using something like content: new Buffer(res.content) would give you an error, you should try with just: content: res.content



  • the same error keeps coming, or maybe install badly nodemailer. I can not solve it, help me

    Error while executing user script. Unable to find module nodemailer
    Searched paths:
    nodemailer
    /app/nodemailer
    .

    77 |
    78 | function afterRender(req, res, done) {

    79 | var mailer = require('nodemailer');
    | ^
    80 |
    81 | var smtpTransport = nodemailer.createTransport('smtps://malca.kike.9%40gmail.com:6XK1x&7Z@smtp.gmail.com');
    82 |

    Error: Unable to find module nodemailer
    Searched paths:
    nodemailer
    /app/nodemailer

    at doRequire (/app/node_modules/jsreport-core/lib/render/safeSandbox.js:232:11)
    at _require (/app/node_modules/jsreport-core/lib/render/safeSandbox.js:72:14)
    at Object.apply (/app/node_modules/vm2/lib/contextify.js:288:34)
    at Object.afterRender (evaluate-user-script.js:79:18)
    at __runAfter (/app/node_modules/jsreport-scripts/lib/scriptEvalChild.js:120:26)
    at Object.apply (/app/node_modules/vm2/lib/contextify.js:288:34)
    at evaluate-user-script.js:110:1
    at ContextifyScript.Script.runInContext (vm.js:59:29)
    at VM.run (/app/node_modules/vm2/lib/main.js:212:72)
    at run (/app/node_modules/jsreport-core/lib/render/safeSandbox.js:183:19)

  • administrators

    with only that information it is not possible for me to tell what can be wrong, please share the following details

    • node, npm version
    • jsreport version
    • the command that you use to start jsreport
    • jsreport startup logs
    • jsreport logs when you hit this error
    • the result of the command npm ls nodemailer
    • the path that you are using as directory of your project (i guess it is /app, according to your logs)
    • the jsreport.config.json file content that you are using
    • the package.json content that you are using in your project


    • the result of the command npm ls nodemailer

    sistemas@noroil-s02:~$ npm ls nodemailer
    /home/sistemas
    └── nodemailer@6.1.0



  • I installed it like this, is it okay?

    sistemas@noroil-s02:~$ npm install nodemailer
    ▀ ╢░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░╟
    WARN engine nodemailer@6.1.0: wanted: {"node":">=6.0.0"} (current: {"node":"4.2.6","npm":"3.5.2"})
    WARN engine nodemailer@6.1.0: wanted: {"node":">=6.0.0"} (current: {"node":"4.2./home/sistemas
    └── nodemailer@6.1.0

    npm WARN enoent ENOENT: no such file or directory, open '/home/sistemas/package.json'
    npm WARN sistemas No description
    npm WARN sistemas No repository field.
    npm WARN sistemas No README data
    npm WARN sistemas No license field.


Log in to reply
 

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.