add smtp user/pass to schema and help docs

Signed-off-by: si458 <simonsmith5521@gmail.com>
This commit is contained in:
si458 2024-04-18 20:22:25 +01:00
parent ca868afdd1
commit f39b6f8859
2 changed files with 120 additions and 14 deletions

View File

@ -317,7 +317,12 @@ The password recovery flow when “Reset Account” is triggered at the login pa
![](images/2022-05-19-00-00-18.png)
Both account verification and password recovery are triggered automatically once SMTP mail server configuration is included into the config.json file. Update the config.json with “smtp” section as shown below and restart the server.
Both account verification and password recovery are triggered automatically once SMTP mail server configuration is included into the config.json file.
#### SMTP: User/Pass
##### Normal Server
Update the config.json with “smtp” section as shown below and restart the server.
```json
{
@ -325,9 +330,9 @@ Both account verification and password recovery are triggered automatically once
"host": "smtp.server.com",
"port": 25,
"from": "myaddress@server.com",
"user": "myaddress@server.com", Optional
"pass": "mypassword", Optional
"tls": false Optional, default false
"user": "myaddress@server.com", # Optional
"pass": "mypassword", # Optional
"tls": false # Optional, default false
}
}
```
@ -336,7 +341,6 @@ Please map the host, port values to connect to the right host that provides this
Some SMTP servers will require a valid username and password to login to the mail server. This is to prevent unauthorized e-mail correspondence. TLS option can be set to true if the SMTP server requires TLS.
#### SMTP: User/Pass
##### Gmail
One option is to configure MeshCentral work with Google Gmail by setting “host” with smtp.gmail.com, and “port” with 587. In the config.json file, use users Gmail address for both “from” and “user” and Gmail password in the “pass” value. You will also need to enable “Less secure app access” in for this Google account. Its in the account settings, security section:
@ -548,14 +552,14 @@ To make this happen, we will be using the following command line options from Me
| --dblistconfigfiles | List the names and size of all configuration files in the database. |
| --dbshowconfigfile (filename) | Show the content of a specified filename from the database. --configkey is required. |
| --dbdeleteconfigfiles | Delete all configuration files from the database. |
| --dbpushconfigfiles (*) or (folder path) | Push a set of configuration files into the database, removing any existing files in the process. When * is specified, the “meshcentral-data” folder up pushed into the database. --configkey is required. |
| --dbpushconfigfiles '*' or (folder path) | Push a set of configuration files into the database, removing any existing files in the process. When * is specified, the “meshcentral-data” folder up pushed into the database. --configkey is required. |
| --dbpullconfigfiles (folder path) | Get all of the configuration files from the database and place them in the specified folder. Files in the target folder may be overwritten. --configkey is required. |
| --loadconfigfromdb (key) | Runs MeshCentral server using the configuration files found in the database. The configkey may be specified with this command or --configkey can be used. |
Once we have MeshCentral running as expected using the “meshcentral-data” folder, we can simply push that configuration into the database and run using the database alone like this:
```
node ./node_modules/meshcentral --dbpushconfigfiles * --configkey mypassword
node ./node_modules/meshcentral --dbpushconfigfiles '*' --configkey mypassword
node ./node_modules/meshcentral --loadconfigfromdb mypassword --mongodb "mongodb://127.0.0.1:27017/meshcentral"
```

View File

@ -2677,7 +2677,7 @@
"name": {
"type": "string",
"format": "hostname",
"description": "Optional hostname of the client, this defaults to the hostname of the machine. This is useful for SMTP relays."
"description": "Optional hostname of the client, this defaults to the hostname of the machine. This is useful for SMTP relays. This can also be set to \"console\" for console output debugging."
},
"host": {
"type": "string",
@ -2688,18 +2688,32 @@
"type": "integer",
"minimum": 1,
"maximum": 65535,
"description": "SMTP server port number."
"default": 587,
"description": "SMTP server port number. This defaults to 587 if \"tls\" is false or 465 if \"tls\" is true)"
},
"from": {
"type": "string",
"format": "email",
"description": "Email address used in the messages from field."
},
"user": {
"type": "string",
"format": "string",
"description": "SMTP username."
},
"pass": {
"type": "string",
"format": "string",
"description": "SMTP password."
},
"tls": {
"type": "boolean"
"type": "boolean",
"default": false,
"description": "Set SMTP to use TLS on connections, the default is false"
},
"auth": {
"type": "object",
"description": "This is used for OAuth2 authentication",
"properties": {
"clientId": {
"type": "string"
@ -2709,6 +2723,11 @@
},
"refreshToken": {
"type": "string"
},
"type": {
"type": "string",
"default": "login",
"description": "Setting this indicates the authetication type, 'login' as default or 'oauth2'"
}
},
"required": [
@ -2735,7 +2754,10 @@
}
},
"required": [
"from"
"host",
"port",
"from",
"tls"
]
},
"sendmail": {
@ -3558,22 +3580,67 @@
"description": "Connects MeshCentral to a SMTP email server, allows MeshCentral to send email messages for 2FA or user notification.",
"type": "object",
"properties": {
"name": {
"type": "string",
"format": "hostname",
"description": "Optional hostname of the client, this defaults to the hostname of the machine. This is useful for SMTP relays. This can also be set to \"console\" for console output debugging."
},
"host": {
"type": "string",
"format": "hostname"
"format": "hostname",
"description": "Hostname of the SMTP server."
},
"port": {
"type": "integer",
"minimum": 1,
"maximum": 65535
"maximum": 65535,
"default": 587,
"description": "SMTP server port number. This defaults to 587 if \"tls\" is false or 465 if \"tls\" is true)"
},
"from": {
"type": "string",
"format": "email",
"description": "Email address used in the messages from field."
},
"user": {
"type": "string",
"format": "string",
"description": "SMTP username."
},
"pass": {
"type": "string",
"format": "string",
"description": "SMTP password."
},
"tls": {
"type": "boolean"
"type": "boolean",
"default": false,
"description": "Set SMTP to use TLS on connections, the default is false"
},
"auth": {
"type": "object",
"description": "This is used for OAuth2 authentication",
"properties": {
"clientId": {
"type": "string"
},
"clientSecret": {
"type": "string"
},
"refreshToken": {
"type": "string"
},
"type": {
"type": "string",
"default": "login",
"description": "Setting this indicates the authetication type, 'login' as default or 'oauth2'"
}
},
"required": [
"clientId",
"clientSecret",
"refreshToken"
]
},
"tlscertcheck": {
"type": "boolean"
@ -3585,6 +3652,11 @@
"type": "boolean",
"default": true,
"description": "When set to false, the email format and DNS MX record are not checked."
},
"emailDelaySeconds": {
"type": "integer",
"default": 300,
"description": "Time to wait before sending a device connection/disconnection notification email. If many events occur, they will be merged into a single email."
}
},
"required": [
@ -3594,6 +3666,36 @@
"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"
},
"emailDelaySeconds": {
"type": "integer",
"default": 300,
"description": "Time to wait before sending a device connection/disconnection notification email. If many events occur, they will be merged into a single email."
}
}
},
"sms": {
"title": "SMS provider",
"description": "Connects MeshCentral to a SMS text messaging provider, allows MeshCentral to send SMS messages for 2FA or user notification.",