Răsfoiți Sursa

Closes #4632: Extend email configuration parameters to support SSL/TLS

Jeremy Stretch 5 ani în urmă
părinte
comite
569d4ee201

+ 14 - 10
docs/configuration/optional-settings.md

@@ -108,16 +108,20 @@ The file path to NetBox's documentation. This is used when presenting context-se
 
 
 ## EMAIL
 ## EMAIL
 
 
-In order to send email, NetBox needs an email server configured. The following items can be defined within the `EMAIL` setting:
-
-* SERVER - Host name or IP address of the email server (use `localhost` if running locally)
-* PORT - TCP port to use for the connection (default: 25)
-* USERNAME - Username with which to authenticate
-* PASSSWORD - Password with which to authenticate
-* TIMEOUT - Amount of time to wait for a connection (seconds)
-* FROM_EMAIL - Sender address for emails sent by NetBox
-
-Email is sent from NetBox only for critical events. If you would like to test the email server configuration please use the django function [send_mail()](https://docs.djangoproject.com/en/stable/topics/email/#send-mail):
+In order to send email, NetBox needs an email server configured. The following items can be defined within the `EMAIL` configuration parameter:
+
+* `SERVER` - Host name or IP address of the email server (use `localhost` if running locally)
+* `PORT` - TCP port to use for the connection (default: `25`)
+* `USERNAME` - Username with which to authenticate
+* `PASSSWORD` - Password with which to authenticate
+* `USE_SSL` - Use SSL when connecting to the server (default: `False`). Mutually exclusive with `USE_TLS`.
+* `USE_TLS` - Use TLS when connecting to the server (default: `False`). Mutually exclusive with `USE_SSL`.
+* `SSL_CERTFILE` - Path to the PEM-formatted SSL certificate file (optional)
+* `SSL_KEYFILE` - Path to the PEM-formatted SSL private key file (optional)
+* `TIMEOUT` - Amount of time to wait for a connection, in seconds (default: `10`)
+* `FROM_EMAIL` - Sender address for emails sent by NetBox (default: `root@localhost`)
+
+Email is sent from NetBox only for critical events or if configured for [logging](#logging). If you would like to test the email server configuration please use the django function [send_mail()](https://docs.djangoproject.com/en/stable/topics/email/#send-mail):
 
 
 ```
 ```
 # python ./manage.py nbshell
 # python ./manage.py nbshell

+ 4 - 0
docs/release-notes/version-2.8.md

@@ -2,6 +2,10 @@
 
 
 v2.8.4 (FUTURE)
 v2.8.4 (FUTURE)
 
 
+### Enhancements
+
+* [#4632](https://github.com/netbox-community/netbox/issues/4632) - Extend email configuration parameters to support SSL/TLS
+
 ### Bug Fixes
 ### Bug Fixes
 
 
 * [#4598](https://github.com/netbox-community/netbox/issues/4598) - Display error message when invalid cable length is specified
 * [#4598](https://github.com/netbox-community/netbox/issues/4598) - Display error message when invalid cable length is specified

+ 2 - 0
netbox/netbox/configuration.example.py

@@ -108,6 +108,8 @@ EMAIL = {
     'PORT': 25,
     'PORT': 25,
     'USERNAME': '',
     'USERNAME': '',
     'PASSWORD': '',
     'PASSWORD': '',
+    'USE_SSL': False,
+    'USE_TLS': False,
     'TIMEOUT': 10,  # seconds
     'TIMEOUT': 10,  # seconds
     'FROM_EMAIL': '',
     'FROM_EMAIL': '',
 }
 }

+ 6 - 2
netbox/netbox/settings.py

@@ -246,12 +246,16 @@ if SESSION_FILE_PATH is not None:
 #
 #
 
 
 EMAIL_HOST = EMAIL.get('SERVER')
 EMAIL_HOST = EMAIL.get('SERVER')
-EMAIL_PORT = EMAIL.get('PORT', 25)
 EMAIL_HOST_USER = EMAIL.get('USERNAME')
 EMAIL_HOST_USER = EMAIL.get('USERNAME')
 EMAIL_HOST_PASSWORD = EMAIL.get('PASSWORD')
 EMAIL_HOST_PASSWORD = EMAIL.get('PASSWORD')
+EMAIL_PORT = EMAIL.get('PORT', 25)
+EMAIL_SSL_CERTFILE = EMAIL.get('SSL_CERTFILE')
+EMAIL_SSL_KEYFILE = EMAIL.get('SSL_KEYFILE')
+EMAIL_SUBJECT_PREFIX = '[NetBox] '
+EMAIL_USE_SSL = EMAIL.get('USE_SSL', False)
+EMAIL_USE_TLS = EMAIL.get('USE_TLS', False)
 EMAIL_TIMEOUT = EMAIL.get('TIMEOUT', 10)
 EMAIL_TIMEOUT = EMAIL.get('TIMEOUT', 10)
 SERVER_EMAIL = EMAIL.get('FROM_EMAIL')
 SERVER_EMAIL = EMAIL.get('FROM_EMAIL')
-EMAIL_SUBJECT_PREFIX = '[NetBox] '
 
 
 
 
 #
 #