diff --git a/meshcentral-config-schema.json b/meshcentral-config-schema.json index 7e4603d7..af01f912 100644 --- a/meshcentral-config-schema.json +++ b/meshcentral-config-schema.json @@ -751,6 +751,16 @@ }, "required": [ "host", "port", "from", "tls" ] }, + "sendmail": { + "title" : "Send email using the sendmail command", + "description": "Makes MeshCentral send emails using the Unix sendmail command. Allows MeshCentral to send email messages for 2FA or user notification.", + "type": "object", + "properties": { + "newline": { "type": "string", "default": "unix", "description": "Possible values are unix or windows" }, + "path": { "type": "string", "default": "sendmail", "description": "Path to the sendmail command" }, + "args": { "type": "array", "items": { "type": "string" }, "default": null, "description": "Array or arguments to pass to sendmail" } + } + }, "authStrategies": { "type": "object", "additionalProperties": false, diff --git a/meshcentral.js b/meshcentral.js index 08325a68..0b441d90 100644 --- a/meshcentral.js +++ b/meshcentral.js @@ -735,7 +735,7 @@ function CreateMeshCentralServer(config, args) { } // Check top level configuration for any unreconized values - 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 ]); } } } + 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 ]); } } } 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(','); } } 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(','); } } diff --git a/meshmail.js b/meshmail.js index 9bea875c..df8ffa90 100644 --- a/meshmail.js +++ b/meshmail.js @@ -52,6 +52,14 @@ module.exports.CreateMeshMail = function (parent, domain) { if ((obj.config.smtp.user != null) && (obj.config.smtp.pass != null)) { options.auth = { user: obj.config.smtp.user, pass: obj.config.smtp.pass }; } if (obj.config.smtp.verifyemail == true) { obj.verifyemail = true; } obj.smtpServer = nodemailer.createTransport(options); + } else if (obj.config.sendmail != null) { + // Setup Sendmail + const nodemailer = require('nodemailer'); + var options = { sendmail: true }; + if (typeof obj.config.smtp.newline == 'string') { options.newline = obj.config.smtp.newline; } + if (typeof obj.config.smtp.path == 'string') { options.path = obj.config.smtp.path; } + if (Array.isArray(obj.config.smtp.args)) { options.args = obj.config.smtp.args; } + obj.smtpServer = nodemailer.createTransport(options); } // Get the correct mail template object diff --git a/sample-config-advanced.json b/sample-config-advanced.json index 6d6f08fb..8511b69b 100644 --- a/sample-config-advanced.json +++ b/sample-config-advanced.json @@ -467,6 +467,11 @@ "from": "myemail@myserver.com", "apikey": "***********" }, + "_sendmail": { + "newline": "unix", + "path": "/usr/sbin/sendmail", + "_args": [ "-f", "foo@example.com" ] + }, "_sms": { "provider": "twilio", "sid": "ACxxxxxxxxx",