Added Sendmail support, #3299
Ylian Saint-Hilaire committed
Nov 25, 2021 at 10:34 UTC
58f611ce72e2c8638ebdd46a9bba3ffbca1299e1
4 files changed
+24
-1
meshcentral-config-schema.json
+10
@@ -751,6 +751,16 @@
751
},
752
"required": [ "host", "port", "from", "tls" ]
753
},
754
+ "sendmail": {
755
+ "title" : "Send email using the sendmail command",
756
+ "description": "Makes MeshCentral send emails using the Unix sendmail command. Allows MeshCentral to send email messages for 2FA or user notification.",
757
+ "type": "object",
758
+ "properties": {
759
+ "newline": { "type": "string", "default": "unix", "description": "Possible values are unix or windows" },
760
+ "path": { "type": "string", "default": "sendmail", "description": "Path to the sendmail command" },
761
+ "args": { "type": "array", "items": { "type": "string" }, "default": null, "description": "Array or arguments to pass to sendmail" }
762
+ }
763
+ },
764
"authStrategies": {
765
"type": "object",
766
"additionalProperties": false,
meshcentral.js
+1
-1
@@ -735,7 +735,7 @@ function CreateMeshCentralServer(config, args) {
735
}
736
737
// Check top level configuration for any unreconized values
738
- if (config) { for (var i in config) { if ((typeof i == 'string') && (i.length > 0) && (i[0] != '_') && (['settings', 'domaindefaults', 'domains', 'configfiles', 'smtp', 'letsencrypt', 'peers', 'sms', 'sendgrid', 'firebase', 'firebaserelay', '$schema'].indexOf(i) == -1)) { addServerWarning('Unrecognized configuration option \"' + i + '\".', 3, [ i ]); } } }
738
+ if (config) { for (var i in config) { if ((typeof i == 'string') && (i.length > 0) && (i[0] != '_') && (['settings', 'domaindefaults', 'domains', 'configfiles', 'smtp', 'letsencrypt', 'peers', 'sms', 'sendgrid', 'sendmail', 'firebase', 'firebaserelay', '$schema'].indexOf(i) == -1)) { addServerWarning('Unrecognized configuration option \"' + i + '\".', 3, [ i ]); } } }
739
740
if (typeof obj.args.userallowedip == 'string') { if (obj.args.userallowedip == '') { config.settings.userallowedip = obj.args.userallowedip = null; } else { config.settings.userallowedip = obj.args.userallowedip = obj.args.userallowedip.split(','); } }
741
if (typeof obj.args.userblockedip == 'string') { if (obj.args.userblockedip == '') { config.settings.userblockedip = obj.args.userblockedip = null; } else { config.settings.userblockedip = obj.args.userblockedip = obj.args.userblockedip.split(','); } }
meshmail.js
+8
@@ -52,6 +52,14 @@ module.exports.CreateMeshMail = function (parent, domain) {
52
if ((obj.config.smtp.user != null) && (obj.config.smtp.pass != null)) { options.auth = { user: obj.config.smtp.user, pass: obj.config.smtp.pass }; }
53
if (obj.config.smtp.verifyemail == true) { obj.verifyemail = true; }
54
obj.smtpServer = nodemailer.createTransport(options);
55
+ } else if (obj.config.sendmail != null) {
56
+ // Setup Sendmail
57
+ const nodemailer = require('nodemailer');
58
+ var options = { sendmail: true };
59
+ if (typeof obj.config.smtp.newline == 'string') { options.newline = obj.config.smtp.newline; }
60
+ if (typeof obj.config.smtp.path == 'string') { options.path = obj.config.smtp.path; }
61
+ if (Array.isArray(obj.config.smtp.args)) { options.args = obj.config.smtp.args; }
62
+ obj.smtpServer = nodemailer.createTransport(options);
63
}
64
65
// Get the correct mail template object
sample-config-advanced.json
+5
@@ -467,6 +467,11 @@
467
"from": "myemail@myserver.com",
468
"apikey": "***********"
469
},
470
+ "_sendmail": {
471
+ "newline": "unix",
472
+ "path": "/usr/sbin/sendmail",
473
+ "_args": [ "-f", "foo@example.com" ]
474
+ },
475
"_sms": {
476
"provider": "twilio",
477
"sid": "ACxxxxxxxxx",