This commit is contained in:
Anton Suhorukov 2023-05-05 11:53:01 +03:00
parent 006b58e405
commit c93374d10a
2 changed files with 23 additions and 1 deletions

View File

@ -81,7 +81,7 @@ public class SmtpSettingsController : ControllerBase
_permissionContext.DemandPermissions(SecutiryConstants.EditPortalSettings);
var settingConfig = _mapper.Map<SmtpSettingsDto, SmtpSettings>(inDto);
var settingConfig = ToSmtpSettingsConfig(inDto);
_coreConfiguration.SmtpSettings = settingConfig;
@ -91,6 +91,26 @@ public class SmtpSettingsController : ControllerBase
return settings;
}
private SmtpSettings ToSmtpSettingsConfig(SmtpSettingsDto inDto)
{
var settingsConfig = new SmtpSettings(
inDto.Host,
inDto.Port ?? SmtpSettings.DefaultSmtpPort,
inDto.SenderAddress,
inDto.SenderDisplayName)
{
EnableSSL = inDto.EnableSSL,
EnableAuth = inDto.EnableAuth
};
if (inDto.EnableAuth)
{
settingsConfig.SetCredentials(inDto.CredentialsUserName, inDto.CredentialsUserPassword);
}
return settingsConfig;
}
[HttpDelete("smtp")]
public SmtpSettingsDto ResetSmtpSettings()
{

View File

@ -143,6 +143,8 @@ public class SmtpJob : DistributedTaskProgress
PublishChanges();
client.Send(FormatOptions.Default, mimeMessage);
Percentage = 100;
}
catch (AuthorizingException authError)
{