diff --git a/src/Core/Core.csproj b/src/Core/Core.csproj
index 0b05d4066f..a179aef21d 100644
--- a/src/Core/Core.csproj
+++ b/src/Core/Core.csproj
@@ -43,7 +43,7 @@
-
+
@@ -52,7 +52,6 @@
-
diff --git a/src/Core/GlobalSettings.cs b/src/Core/GlobalSettings.cs
index 2d26949f9c..7a216bfe7f 100644
--- a/src/Core/GlobalSettings.cs
+++ b/src/Core/GlobalSettings.cs
@@ -114,7 +114,6 @@ namespace Bit.Core
public class MailSettings
{
public string ReplyToEmail { get; set; }
- public string SendGridApiKey { get; set; }
public string AmazonConfigSetName { get; set; }
public SmtpSettings Smtp { get; set; } = new SmtpSettings();
diff --git a/src/Core/Services/Implementations/SendGridMailDeliveryService.cs b/src/Core/Services/Implementations/SendGridMailDeliveryService.cs
deleted file mode 100644
index b510af13db..0000000000
--- a/src/Core/Services/Implementations/SendGridMailDeliveryService.cs
+++ /dev/null
@@ -1,98 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Threading.Tasks;
-using SendGrid;
-using SendGrid.Helpers.Mail;
-using Bit.Core.Models.Mail;
-using System.Linq;
-using System.Net;
-using System.Net.Http;
-
-namespace Bit.Core.Services
-{
- public class SendGridMailDeliveryService : IMailDeliveryService
- {
- private readonly GlobalSettings _globalSettings;
- private readonly SendGridClient _client;
-
- public SendGridMailDeliveryService(GlobalSettings globalSettings)
- {
- if(globalSettings.Mail?.SendGridApiKey == null)
- {
- throw new ArgumentNullException(nameof(globalSettings.Mail.SendGridApiKey));
- }
-
- _globalSettings = globalSettings;
- _client = new SendGridClient(_globalSettings.Mail.SendGridApiKey);
- }
-
- public async Task SendEmailAsync(MailMessage message)
- {
- var sendGridMessage = new SendGridMessage
- {
- Subject = message.Subject,
- From = new EmailAddress(_globalSettings.Mail.ReplyToEmail, _globalSettings.SiteName),
- HtmlContent = message.HtmlContent,
- PlainTextContent = message.TextContent
- };
-
- sendGridMessage.SetClickTracking(true, false);
- sendGridMessage.SetOpenTracking(true, null);
- sendGridMessage.AddTos(message.ToEmails.Select(e => new EmailAddress(e)).ToList());
- if(message.BccEmails?.Any() ?? false)
- {
- sendGridMessage.AddBccs(message.BccEmails.Select(e => new EmailAddress(e)).ToList());
- }
-
- if(message.MetaData?.ContainsKey("SendGridTemplateId") ?? false)
- {
- sendGridMessage.HtmlContent = " ";
- sendGridMessage.PlainTextContent = " ";
- sendGridMessage.TemplateId = message.MetaData["SendGridTemplateId"].ToString();
- }
-
- if(message.MetaData?.ContainsKey("SendGridSubstitutions") ?? false)
- {
- var subs = message.MetaData["SendGridSubstitutions"] as Dictionary;
- sendGridMessage.AddSubstitutions(subs);
- }
-
- var cats = new List { "Bitwarden Server" };
- if(!string.IsNullOrWhiteSpace(message.Category))
- {
- cats.Add(message.Category);
- }
- sendGridMessage.AddCategories(cats);
-
- if(message.MetaData?.ContainsKey("SendGridBypassListManagement") ?? false)
- {
- var bypass = message.MetaData["SendGridBypassListManagement"] as bool?;
- sendGridMessage.SetBypassListManagement(bypass.GetValueOrDefault(false));
- }
-
- try
- {
- await SendAsync(sendGridMessage, false);
- }
- catch(HttpRequestException)
- {
- await SendAsync(sendGridMessage, true);
- }
- catch(WebException)
- {
- await SendAsync(sendGridMessage, true);
- }
- }
-
- private async Task SendAsync(SendGridMessage sendGridMessage, bool retry)
- {
- if(retry)
- {
- // wait and try again
- await Task.Delay(2000);
- }
-
- await _client.SendEmailAsync(sendGridMessage);
- }
- }
-}
diff --git a/src/Core/Utilities/ServiceCollectionExtensions.cs b/src/Core/Utilities/ServiceCollectionExtensions.cs
index 23b0f0e71f..a79eb08655 100644
--- a/src/Core/Utilities/ServiceCollectionExtensions.cs
+++ b/src/Core/Utilities/ServiceCollectionExtensions.cs
@@ -128,11 +128,7 @@ namespace Bit.Core.Utilities
services.AddSingleton();
}
- if(CoreHelpers.SettingHasValue(globalSettings.Mail.SendGridApiKey))
- {
- services.AddSingleton();
- }
- else if(CoreHelpers.SettingHasValue(globalSettings.Amazon?.AccessKeySecret))
+ if(CoreHelpers.SettingHasValue(globalSettings.Amazon?.AccessKeySecret))
{
services.AddSingleton();
}
diff --git a/test/Core.Test/Services/SendGridMailDeliveryServiceTests.cs b/test/Core.Test/Services/SendGridMailDeliveryServiceTests.cs
deleted file mode 100644
index f2691208b5..0000000000
--- a/test/Core.Test/Services/SendGridMailDeliveryServiceTests.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-using System;
-using Bit.Core.Services;
-using NSubstitute;
-using Xunit;
-
-namespace Bit.Core.Test.Services
-{
- public class SendGridMailDeliveryServiceTests
- {
- private readonly SendGridMailDeliveryService _sut;
-
- private readonly GlobalSettings _globalSettings;
-
- public SendGridMailDeliveryServiceTests()
- {
- _globalSettings = new GlobalSettings();
-
- _sut = new SendGridMailDeliveryService(_globalSettings);
- }
-
- // Remove this test when we add actual tests. It only proves that
- // we've properly constructed the system under test.
- [Fact(Skip = "Needs additional work")]
- public void ServiceExists()
- {
- Assert.NotNull(_sut);
- }
- }
-}