Nodemailer SMTP Gmail error



  • Hi i keep receiving the following error when following the https://jsreport.net/learn/periodical-report-sending-through-email instructions.

    Error: Invalid login: 534-5.7.14 534-5.7.14 Please log in via your web browser and then try again. 534-5.7.14 Learn more at 534 5.7.14 https://support.google.com/mail/answer/78754 b68sm10059390wme.6 - gsmtp at SMTPConnection._formatError (/var/www/html/jsreportapp/node_modules/nodemailer/lib/smtp-connection/index.js:784:19) at SMTPConnection._actionAUTHComplete (/var/www/html/jsreportapp/node_modules/nodemailer/lib/smtp-connection/index.js:1523:34) at SMTPConnection._responseActions.push.str (/var/www/html/jsreportapp/node_modules/nodemailer/lib/smtp-connection/index.js:550:26) at SMTPConnection._processResponse (/var/www/html/jsreportapp/node_modules/nodemailer/lib/smtp-connection/index.js:942:20) at SMTPConnection._onData (/var/www/html/jsreportapp/node_modules/nodemailer/lib/smtp-connection/index.js:749:14) at TLSSocket.SMTPConnection._onSocketData.chunk (/var/www/html/jsreportapp/node_modules/nodemailer/lib/smtp-connection/index.js:195:44) at TLSSocket.emit (events.js:198:13) at TLSSocket.EventEmitter.emit (domain.js:466:23) at addChunk (_stream_readable.js:288:12) at readableAddChunk (_stream_readable.js:269:11)

    I am running ubuntu on an AWS EC2 server, the system seems to be setup correctly.

    Here is my afterRender function

    function afterRender(req, res, done) {
        var mailer = require("nodemailer");
    
        var smtpTransport = mailer.createTransport({
            service: 'gmail',
            auth: {
                user: 'email_1',
                pass: 'password'
            }
        });
    
        var mail = {
            from: "email_1",
            to: "email_2",
            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();
        });
    }
    

    and here is my config file

    {
      "extensions": {
        "authentication": {
          "cookieSession": {
            "secret": "<your strong secret here>"
          },
          "admin": {
            "username": "admin",
            "password": "password"
          },
          "enabled": true
        },
        "scripts": {
          "timeout": 40000,
          "strategy": "http-server",
          "allowedModules": ["request", "nodemailer"] 
        },
        "sample-template": {
          "createSamples": true
        }
      },
      "httpPort": 3000,
      "store": {
        "provider": "fs"
      },
      "blobStorage": {
        "provider": "fs"
      },
      "logger": {
        "console": {
          "transport": "console",
          "level": "debug"
        },
        "file": {
          "transport": "file",
          "level": "info",
          "filename": "logs/reporter.log"
        },
        "error": {
          "transport": "file",
          "level": "error",
          "filename": "logs/error.log"
        }
      },
      "allowLocalFilesAccess": true,
      "templatingEngines": {
        "timeout": 10000,
        "strategy": "http-server"
      },
      "chrome": {
        "timeout": 40000
      }
    }
    

    I am 100% sure my credentials are correct since I use them on other systems.


  • administrators

    hi! hmm i'm not sure what can be the issue, but in any case this does not look like an issue with jsreport itself, maybe the nodemailer changed its api a bit since the post was made, you probably need to check the nodemailer docs and verify that the options you are using are the correct ones.


Log in to reply
 

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