#8142 - Added smtp authentication if username or password provided

This commit is contained in:
Bjarke Berg
2020-05-20 12:38:21 +02:00
parent a120b9cffb
commit 490ae37b28
@@ -48,7 +48,15 @@ namespace Umbraco.Core
{
using (var client = new SmtpClient())
{
client.Connect(_globalSettings.SmtpSettings.Host, _globalSettings.SmtpSettings.Port);
if (!(_globalSettings.SmtpSettings.Username is null &&
_globalSettings.SmtpSettings.Password is null))
{
client.Authenticate(_globalSettings.SmtpSettings.Username, _globalSettings.SmtpSettings.Password);
}
client.Send(ConstructEmailMessage(message));
client.Disconnect(true);
}
@@ -72,6 +80,12 @@ namespace Umbraco.Core
{
await client.ConnectAsync(_globalSettings.SmtpSettings.Host, _globalSettings.SmtpSettings.Port);
if (!(_globalSettings.SmtpSettings.Username is null &&
_globalSettings.SmtpSettings.Password is null))
{
await client.AuthenticateAsync(_globalSettings.SmtpSettings.Username, _globalSettings.SmtpSettings.Password);
}
var mailMessage = ConstructEmailMessage(message);
if (_globalSettings.SmtpSettings.DeliveryMethod == SmtpDeliveryMethod.Network)
{