perf: Update email settings to use SECURITY_PROTOCOL instead of EMAIL_USE_SSL

This commit is contained in:
wangruidong
2025-07-21 17:23:19 +08:00
parent 8f91cb1473
commit 366d07a257
5 changed files with 17 additions and 5 deletions

View File

@@ -1558,5 +1558,6 @@
"removeWarningMsg": "Are you sure you want to remove",
"setVariable": "Set variable",
"userId": "User ID",
"userName": "User name"
"userName": "User name",
"EmailHelpText": "Please click the 'Submit' button to save the current configuration before clicking 'Test Connection' to ensure the settings take effect."
}

View File

@@ -1563,5 +1563,6 @@
"removeWarningMsg": "你确定要移除",
"setVariable": "设置参数",
"userId": "用户ID",
"userName": "用户名"
"userName": "用户名",
"EmailHelpText": "请点击'提交'按钮保存当前配置后,再点击'测试连接'以确保信息生效"
}

View File

@@ -541,6 +541,7 @@ class Config(dict):
'EMAIL_CUSTOM_USER_CREATED_SUBJECT': _('Create account successfully'),
'EMAIL_CUSTOM_USER_CREATED_HONORIFIC': _('Hello'),
'EMAIL_CUSTOM_USER_CREATED_BODY': _('Your account has been created successfully'),
'EMAIL_SECURITY_PROTOCOL': 'none',
'OTP_VALID_WINDOW': 2,
'OTP_ISSUER_NAME': 'JumpServer',

View File

@@ -328,7 +328,7 @@ EMAIL_HOST_USER = CONFIG.EMAIL_HOST_USER
EMAIL_HOST_PASSWORD = CONFIG.EMAIL_HOST_PASSWORD
EMAIL_FROM = CONFIG.EMAIL_FROM
EMAIL_RECIPIENT = CONFIG.EMAIL_RECIPIENT
EMAIL_USE_SSL = CONFIG.EMAIL_USE_SSL
EMAIL_SECURITY_PROTOCOL = CONFIG.EMAIL_SECURITY_PROTOCOL
EMAIL_USE_TLS = CONFIG.EMAIL_USE_TLS
# Custom User Auth model

View File

@@ -24,6 +24,11 @@ class EmailSettingSerializer(serializers.Serializer):
smtp = 'smtp', _('SMTP')
exchange = 'exchange', _('EXCHANGE')
class SECURITY_PROTOCOL(models.TextChoices):
none = 'none', _('None')
ssl = 'ssl', _('Use SSL')
tls = 'tls', _('Use TLS')
EMAIL_PROTOCOL = serializers.ChoiceField(
choices=EmailProtocol.choices, label=_("Protocol"), default=EmailProtocol.smtp
)
@@ -34,8 +39,8 @@ class EmailSettingSerializer(serializers.Serializer):
help_text=_("The user to be used for email server authentication")
)
EMAIL_HOST_PASSWORD = EncryptedField(
max_length=1024, required=False, label=_("Password"),
help_text=_("Password to use for the email server. It is used in conjunction with `User` when authenticating to the email server")
max_length=1024, required=False, label=_("Password"), help_text=_(
"Password to use for the email server. It is used in conjunction with `User` when authenticating to the email server")
)
EMAIL_FROM = serializers.CharField(
max_length=128, allow_blank=True, required=False, label=_('Sender'),
@@ -55,6 +60,10 @@ class EmailSettingSerializer(serializers.Serializer):
help_text=_(
'Whether to use a TLS (secure) connection when talking to the SMTP server. This is used for explicit TLS connections, generally on port 587')
)
EMAIL_SECURITY_PROTOCOL = serializers.ChoiceField(
choices=SECURITY_PROTOCOL.choices, label=_("TLS/SSL"),
default=SECURITY_PROTOCOL.none
)
class EmailContentSettingSerializer(serializers.Serializer):