1
0
mirror of https://github.com/bitwarden/server.git synced 2025-05-22 20:11:04 -05:00

allow custom smtp auth type

This commit is contained in:
Kyle Spearrin 2018-08-22 23:40:50 -04:00
parent d992125b5f
commit 61d2ba644c
2 changed files with 15 additions and 2 deletions

View File

@ -103,6 +103,7 @@ namespace Bit.Core
public string Username { get; set; }
public string Password { get; set; }
public bool UseDefaultCredentials { get; set; } = false;
public string AuthType { get; set; }
}
}

View File

@ -35,8 +35,20 @@ namespace Bit.Core.Services
if(!string.IsNullOrWhiteSpace(_globalSettings.Mail.Smtp.Username) &&
!string.IsNullOrWhiteSpace(_globalSettings.Mail.Smtp.Password))
{
client.Credentials = new NetworkCredential(_globalSettings.Mail.Smtp.Username,
_globalSettings.Mail.Smtp.Password);
if(!string.IsNullOrWhiteSpace(_globalSettings.Mail.Smtp.AuthType))
{
var cred = new NetworkCredential(_globalSettings.Mail.Smtp.Username,
_globalSettings.Mail.Smtp.Password);
var cache = new CredentialCache();
cache.Add(_globalSettings.Mail.Smtp.Host, _globalSettings.Mail.Smtp.Port,
_globalSettings.Mail.Smtp.AuthType, cred);
client.Credentials = cache;
}
else
{
client.Credentials = new NetworkCredential(_globalSettings.Mail.Smtp.Username,
_globalSettings.Mail.Smtp.Password);
}
}
var smtpMessage = new MailMessage();