mirror of
https://github.com/bitwarden/server.git
synced 2024-12-26 17:37:36 +01:00
SMTP config allow no username/password
This commit is contained in:
parent
23eb24c2bc
commit
ce9067a434
@ -92,6 +92,7 @@ namespace Bit.Core
|
||||
public bool Ssl { get; set; } = false;
|
||||
public string Username { get; set; }
|
||||
public string Password { get; set; }
|
||||
public bool UseDefaultCredentials { get; set; } = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,11 +23,16 @@ namespace Bit.Core.Services
|
||||
public Task SendEmailAsync(Models.Mail.MailMessage message)
|
||||
{
|
||||
var client = new SmtpClient(_globalSettings.Mail.Smtp.Host, _globalSettings.Mail.Smtp.Port);
|
||||
client.UseDefaultCredentials = false;
|
||||
client.EnableSsl = _globalSettings.Mail.Smtp.Ssl;
|
||||
client.UseDefaultCredentials = _globalSettings.Mail.Smtp.UseDefaultCredentials;
|
||||
client.DeliveryMethod = SmtpDeliveryMethod.Network;
|
||||
client.Credentials = new NetworkCredential(_globalSettings.Mail.Smtp.Username,
|
||||
_globalSettings.Mail.Smtp.Password);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
var smtpMessage = new MailMessage();
|
||||
smtpMessage.From = new MailAddress(_globalSettings.Mail.ReplyToEmail, _globalSettings.SiteName);
|
||||
|
@ -71,9 +71,7 @@ namespace Bit.Core.Utilities
|
||||
{
|
||||
services.AddSingleton<IMailDeliveryService, SendGridMailDeliveryService>();
|
||||
}
|
||||
else if(CoreHelpers.SettingHasValue(globalSettings.Mail?.Smtp?.Host) &&
|
||||
CoreHelpers.SettingHasValue(globalSettings.Mail?.Smtp?.Username) &&
|
||||
CoreHelpers.SettingHasValue(globalSettings.Mail?.Smtp?.Password))
|
||||
else if(CoreHelpers.SettingHasValue(globalSettings.Mail?.Smtp?.Host))
|
||||
{
|
||||
services.AddSingleton<IMailDeliveryService, SmtpMailDeliveryService>();
|
||||
}
|
||||
|
@ -403,6 +403,7 @@ globalSettings__mail__smtp__username=REPLACE
|
||||
globalSettings__mail__smtp__password=REPLACE
|
||||
globalSettings__mail__smtp__ssl=true
|
||||
globalSettings__mail__smtp__port=587
|
||||
globalSettings__mail__smtp__useDefaultCredentials=false
|
||||
globalSettings__disableUserRegistration=false");
|
||||
|
||||
if(!_push)
|
||||
|
Loading…
Reference in New Issue
Block a user