Nodemailer not sending email after the upgrade to new version



  • Following script was sending email successfully before the upgrade. However, after the upgrade, it's not sending any email and I am not even seeing any error message. Can you please help me figuring out the problem

     var nodemailer = require("nodemailer")
     function afterRender(done) {
    var transporter = nodemailer.createTransport("SMTP",{		
    	host:"servername",
    	port:portnumber
    });
    
    
    var reportType=request.options['report-type']
    if(reportType==='email'){
        var recipient=request.options['recipient']
        var subject=request.options['subject']
        var fileType=request.options['attachment']
        var message=request.options['message']
    
        var attachReport=''
            if(fileType==='pdf'){
                attachReport=[{
                  filename: 'Report.pdf',
                  contents: new Buffer(response.content)
                  }]
            }else if(fileType==='excel'){
                 attachReport=[{
                  filename: 'Report.xlsx',
                  contents: new Buffer(response.content)
                  }]
            }
            
            var mailOptions={
    			from: "DoNotReply@RandomEmail.com", 
    		   	to: recipient, 
    		   	subject: subject, 
    		   	text: message, 	   
    		   	attachments:attachReport							
    		}
            
            //Send Email
            
            transporter.sendMail(mailOptions, function(error, response){ 
        	   if(error){
        	       console.log('ERROR:'+error);	
        	       done()
        	   }else{
        	       console.log("Message sent: " + response.message);							       				       
        	       done();          
        	   }  	
        	});
            
    }
    
    //console.log(request.options)
    
    done()
    
    } 
    

    Here is the config

    {
    "certificate": {
        "key": "certificates/jsreport.net.key",    
        "cert": "certificates/jsreport.net.cert"
    
    },
    "scripts": {
        "allowedModules": ["nodemailer"],
        "timeout": 60000
    },
    "license-key":"we_are_using_license_key",
    "authentication" : {
        "cookieSession": {
            "secret": "<your strong secret>"
        },
        "admin": {
            "username" : "",
            "password": ""
        },
        "enabled": false
    },
    "connectionString": { "name": "fs" },
    "httpPort": portnumber,
    "httpsPort": null,
    "blobStorage": "fileSystem",
    "phantom": {
        "strategy": "dedicated-process",
        "timeout": 60000
    },
    "tasks": {
        "strategy": "dedicated-process",
        "timeout": 10000,
        "allowedModules": []
    }
    
    
    
    }


  • Why do you have done() at the end of the script? Shouldn't it be in the else branch?



  • thanks, it solved my problem.


Log in to reply
 

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