Hi,
I've been having a problem trying to send a email with a .csv file attached. I know how to do it, at least, with a pc, but, for some reason, the raspberry Pi 3 doesn't send the file, despite of that both have the same flows (exept for the site of the file inside the PC). The debug console shows exactly the same msg when I add a debug node just before the e-mail node, so I don't understand what's the problem now and I would like to know if someone had a similar problem using a Raspberry Pi 3, and specially, if someone knows how to solve it.
Here I paste the code used in the Raspberry.
Thanks you, very much.
[{"id":"9358a7d4.f758f8","type":"inject","z":"e121a050.a5197","name":"Daily email","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"00 02 * * *","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":110,"y":1700,"wires":[["90b08b74.7de978","61123edf.1ce33","59124705.4e7df8"]]},{"id":"abc787eb.26d238","type":"file in","z":"e121a050.a5197","name":"get file data","filename":"","format":"","chunk":false,"sendError":false,"encoding":"none","x":750,"y":1620,"wires":[["f2ee8d29.cc06"]]},{"id":"f2ee8d29.cc06","type":"function","z":"e121a050.a5197","name":"write email","func":"file = msg.filename; // create local file variable for convenient reference\nvar d = new Date();\nd.setDate(d.getDate() - 1);// create current date object for the time string\nvar tstring = d.toString().substring(4,15);\nvar n = global.get(\"serial_numbers\");\nvar nstring = n.toString().substring(6,20);\n\nmsg.attachments =\n { filename : file.substring(file.lastIndexOf('/')+1, file.lenght),\n content : msg.payload }; // content should be a file binary buffer\n \nmsg.topic = \"Battery Data logs at \" + tstring + \" of module \" + nstring; // email subject\n\nmsg.payload = \"Please, don't answer this email.\\n \\n \\nHere you have attatched the daily battery data logs of your module: \" + nstring; // email body\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":930,"y":1620,"wires":[["cdf643bd.03c86","831cdbb4.e8ded8"]]},{"id":"831cdbb4.e8ded8","type":"debug","z":"e121a050.a5197","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1130,"y":1580,"wires":[]},{"id":"d3b7b402.b40a48","type":"function","z":"e121a050.a5197","name":"format","func":"flow.set(\"log\", true);\nvar date = msg.payload.split('-');\ndate = date[0].replace(/\\//g, '');\nvar filename = \"/home/pi/Documents/Logs/battery_data \" + date + \".csv\";\nmsg.filename = filename;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":590,"y":1620,"wires":[["abc787eb.26d238"]]},{"id":"90b08b74.7de978","type":"moment","z":"e121a050.a5197","name":"","topic":"","input":"","inputType":"msg","inTz":"Europe/Madrid","adjAmount":"1","adjType":"days","adjDir":"subtract","format":"L-LTS","locale":"es_ES","output":"payload","outputType":"msg","outTz":"Europe/Madrid","x":400,"y":1620,"wires":[["d3b7b402.b40a48"]]},{"id":"721cb58d.f8d34c","type":"file in","z":"e121a050.a5197","name":"get file values","filename":"","format":"","chunk":false,"sendError":false,"encoding":"none","x":760,"y":1700,"wires":[["71ae0a45.ea7d64"]]},{"id":"71ae0a45.ea7d64","type":"function","z":"e121a050.a5197","name":"write email","func":"file = msg.filename; // create local file variable for convenient reference\nvar d = new Date();\nd.setDate(d.getDate() - 1);// create current date object for the time string\nvar tstring = d.toString().substring(4,15);\nvar n = global.get(\"serial_numbers\");\nvar nstring = n.toString().substring(6,20);\n\nmsg.attachments =\n { filename : file.substring(file.lastIndexOf('/')+1,file.length),\n content : msg.payload }; // content should be a file binary buffer\n \nmsg.topic = \"Power values logs at \" + tstring + \" of module \" + nstring; // email subject\n\nmsg.payload = \"Please, don't answer this email.\\n \\n \\nHere you have attatched the daily power values logs of your module: \" + nstring; // email body\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":930,"y":1700,"wires":[["211c83f0.3f6ccc","dd4a51be.14951"]]},{"id":"dd4a51be.14951","type":"debug","z":"e121a050.a5197","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1130,"y":1660,"wires":[]},{"id":"d36692ff.31d7f","type":"function","z":"e121a050.a5197","name":"format","func":"flow.set(\"log\", true);\nvar date = msg.payload.split('-');\ndate = date[0].replace(/\\//g, '');\nvar filename = \"/home/pi/Documents/Logs/power_values \" + date + \".csv\";\nmsg.filename = filename;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":590,"y":1700,"wires":[["721cb58d.f8d34c"]]},{"id":"61123edf.1ce33","type":"moment","z":"e121a050.a5197","name":"","topic":"","input":"","inputType":"msg","inTz":"Europe/Madrid","adjAmount":"1","adjType":"days","adjDir":"subtract","format":"L-LTS","locale":"es_ES","output":"payload","outputType":"msg","outTz":"Europe/Madrid","x":400,"y":1700,"wires":[["d36692ff.31d7f"]]},{"id":"cdf643bd.03c86","type":"e-mail","z":"e121a050.a5197","server":"smtp.gmail.com","port":"465","secure":true,"tls":false,"name":"xxx@gmail.com","dname":"Battery Data Email","x":1170,"y":1620,"wires":[]},{"id":"211c83f0.3f6ccc","type":"e-mail","z":"e121a050.a5197","server":"smtp.gmail.com","port":"465","secure":true,"tls":false,"name":"xxx@gmail.com","dname":"Power Values Email","x":1180,"y":1700,"wires":[]},{"id":"5e799071.d6136","type":"file in","z":"e121a050.a5197","name":"get file warnings","filename":"","format":"","chunk":false,"sendError":false,"encoding":"none","x":760,"y":1780,"wires":[["91ee381f.66a3b8"]]},{"id":"91ee381f.66a3b8","type":"function","z":"e121a050.a5197","name":"write email","func":"file = msg.filename; // create local file variable for convenient reference\nvar d = new Date();\nd.setDate(d.getDate() - 1);// create current date object for the time string\nvar tstring = d.toString().substring(4,15);\nvar n = global.get(\"serial_numbers\");\nvar nstring = n.toString().substring(6,20);\n\nmsg.attachments =\n { filename : file.substring(file.lastIndexOf('/')+1,file.length),\n content : msg.payload }; // content should be a file binary buffer\n \nmsg.topic = \"These are the warning at \" + tstring + \" of module \" + nstring; // email subject\n\nmsg.payload = \"Please, don't answer this email.\\n \\n \\nHere you have attatched the daily warning logs of your module: \" + nstring; // email body\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":930,"y":1780,"wires":[["8330fd8f.21877","c6312613.87a1f8"]]},{"id":"c6312613.87a1f8","type":"debug","z":"e121a050.a5197","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1130,"y":1740,"wires":[]},{"id":"1d70c496.4271bb","type":"function","z":"e121a050.a5197","name":"format","func":"flow.set(\"log\", true);\nvar date = msg.payload.split('-');\ndate = date[0].replace(/\\//g, '');\nvar filename = \"/home/pi/Documents/Logs/warnings \" + date + \".csv\";\nmsg.filename = filename;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":590,"y":1780,"wires":[["5e799071.d6136"]]},{"id":"59124705.4e7df8","type":"moment","z":"e121a050.a5197","name":"","topic":"","input":"","inputType":"msg","inTz":"Europe/Madrid","adjAmount":"1","adjType":"days","adjDir":"subtract","format":"L-LTS","locale":"es_ES","output":"payload","outputType":"msg","outTz":"Europe/Madrid","x":400,"y":1780,"wires":[["1d70c496.4271bb"]]},{"id":"8330fd8f.21877","type":"e-mail","z":"e121a050.a5197","server":"smtp.gmail.com","port":"465","secure":true,"tls":false,"name":"xxx@gmail.com","dname":"Warnings Email","x":1160,"y":1780,"wires":[]}]
Admin edit - removed personal email address