diff --git a/IRaCIS.Core.Application/Helper/SendEmailHelper.cs b/IRaCIS.Core.Application/Helper/SendEmailHelper.cs index 974a60f02..7a223b275 100644 --- a/IRaCIS.Core.Application/Helper/SendEmailHelper.cs +++ b/IRaCIS.Core.Application/Helper/SendEmailHelper.cs @@ -52,15 +52,19 @@ public static class SendEmailHelper public static async Task TestEmailConfigAsync(SystemEmailSendConfig _systemEmailConfig) { - using (var client = new MailKit.Net.Smtp.SmtpClient()) + using (var cts = new CancellationTokenSource(TimeSpan.FromSeconds(5))) { + using (var client = new MailKit.Net.Smtp.SmtpClient()) + { - await client.ConnectAsync(_systemEmailConfig.Host, _systemEmailConfig.Port, SecureSocketOptions.Auto); + await client.ConnectAsync(_systemEmailConfig.Host, _systemEmailConfig.Port, SecureSocketOptions.Auto, cts.Token); - await client.AuthenticateAsync(_systemEmailConfig.FromEmail, _systemEmailConfig.AuthorizationCode); + await client.AuthenticateAsync(_systemEmailConfig.FromEmail, _systemEmailConfig.AuthorizationCode, cts.Token); - await client.DisconnectAsync(true); + await client.DisconnectAsync(true); + } } + return true; } diff --git a/IRaCIS.Core.Application/Service/Document/TrialEmailNoticeConfigService.cs b/IRaCIS.Core.Application/Service/Document/TrialEmailNoticeConfigService.cs index 2103aecef..5698b1e26 100644 --- a/IRaCIS.Core.Application/Service/Document/TrialEmailNoticeConfigService.cs +++ b/IRaCIS.Core.Application/Service/Document/TrialEmailNoticeConfigService.cs @@ -1479,7 +1479,7 @@ namespace IRaCIS.Core.Application.Service { //---发件人配置错误,请核对服务器地址或者授权码是否填写有误 - throw new BusinessValidationFailedException(_localizer["TrialEmailN_InvalidSenderEmailConfig"] + ex.Message); + throw new BusinessValidationFailedException(_localizer["TrialEmailN_InvalidSenderEmailConfig"]); }