mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-16 20:15:44 +00:00
Email config fix (#5336)
* Change for DEFAULT_FROM_EMAIL - Use USERNAME if not specified (cherry picked from commit 487ac917c90e9fe3da4effaa9326b707ceecd321) * Email configuration fails if DEFAULT_FROM_EMAIL not set (cherry picked from commit 01e573c3a2702e7c21ed13b0cb44280c89d3dee1) * Docs update
This commit is contained in:
@ -17,6 +17,7 @@ def is_email_configured():
|
||||
NOTE: This does not check if the configuration is valid!
|
||||
"""
|
||||
configured = True
|
||||
testing = settings.TESTING
|
||||
|
||||
if InvenTree.ready.isInTestMode():
|
||||
return False
|
||||
@ -28,17 +29,24 @@ def is_email_configured():
|
||||
configured = False
|
||||
|
||||
# Display warning unless in test mode
|
||||
if not settings.TESTING: # pragma: no cover
|
||||
if not testing: # pragma: no cover
|
||||
logger.debug("EMAIL_HOST is not configured")
|
||||
|
||||
# Display warning unless in test mode
|
||||
if not settings.EMAIL_HOST_USER and not settings.TESTING: # pragma: no cover
|
||||
if not settings.EMAIL_HOST_USER and not testing: # pragma: no cover
|
||||
logger.debug("EMAIL_HOST_USER is not configured")
|
||||
|
||||
# Display warning unless in test mode
|
||||
if not settings.EMAIL_HOST_PASSWORD and not settings.TESTING: # pragma: no cover
|
||||
if not settings.EMAIL_HOST_PASSWORD and testing: # pragma: no cover
|
||||
logger.debug("EMAIL_HOST_PASSWORD is not configured")
|
||||
|
||||
# Email sender must be configured
|
||||
if not settings.DEFAULT_FROM_EMAIL:
|
||||
configured = False
|
||||
|
||||
if not testing: # pragma: no cover
|
||||
logger.warning("DEFAULT_FROM_EMAIL is not configured")
|
||||
|
||||
return configured
|
||||
|
||||
|
||||
|
@ -832,6 +832,10 @@ EMAIL_USE_SSL = get_boolean_setting('INVENTREE_EMAIL_SSL', 'email.ssl', False)
|
||||
|
||||
DEFAULT_FROM_EMAIL = get_setting('INVENTREE_EMAIL_SENDER', 'email.sender', '')
|
||||
|
||||
# If "from" email not specified, default to the username
|
||||
if not DEFAULT_FROM_EMAIL:
|
||||
DEFAULT_FROM_EMAIL = get_setting('INVENTREE_EMAIL_USERNAME', 'email.username', '')
|
||||
|
||||
EMAIL_USE_LOCALTIME = False
|
||||
EMAIL_TIMEOUT = 60
|
||||
|
||||
|
Reference in New Issue
Block a user