1 const params
= require("../config/parameters");
2 const { exec
} = require('child_process');
6 // o: {from(*), to(*), subject, body} - (*): mandatory
7 send: function(o
, callback
)
11 let subject
= !!o
.subject
? o
.subject : "[No subject]";
12 let body
= !!o
.body
? o
.body : "";
14 // In development mode, just log message:
15 let env
= process
.env
.NODE_ENV
|| 'development';
16 if ('development' === env
)
18 console
.log("New mail: from " + from + " / to " + to
);
19 console
.log("Subject: " + subject
);
20 let msgText
= body
.split('\\n');
21 msgText
.forEach(msg
=> { console
.log(msg
); });
27 "printf 'From: " + from + "\n" +
29 "Subject: " + subject
+ "\n" +
30 body
+ "' | msmtp -a " + params
.mail
.account
+ " " + to
,
31 (err
, stdout
, stderr
) => {
33 // the *entire* stdout and stderr (buffered)
34 //console.log("stdout: " + stdout);
35 //console.log("stderr: " + stderr);
42 module
.exports
= Mailer
;