Skip to content

Commit 903bd33

Browse files
committed
optimize for api instead of smtp
1 parent f0c26f1 commit 903bd33

3 files changed

Lines changed: 5 additions & 16 deletions

File tree

src/DevBetterWeb.Infrastructure/Services/Smtp2GoEmailService.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public class Smtp2GoEmailService : IEmailService
1414
private readonly HttpClient _httpClient;
1515
public Smtp2GoEmailService(IOptions<AuthMessageSenderOptions> optionsAccessor)
1616
{
17+
Guard.Against.Null(optionsAccessor, nameof(optionsAccessor));
1718
Guard.Against.Null(optionsAccessor.Value, nameof(optionsAccessor.Value));
1819
Options = optionsAccessor.Value;
1920
_httpClient = new HttpClient();

src/DevBetterWeb.Web/appsettings.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
"ApiSettings": {
1515
"ApiKey": "[api key string goes here]"
1616
},
17-
"AuthMessageSenderOptions": {
18-
"SmtpServer": "mail.smtp2go.com",
19-
"SmtpPort": 587,
20-
"ApiKey": "[smtp2go api key goes here]"
17+
"ApiMailSenderOptions": {
18+
"ApiBaseUrl": "https://api.smtp2go.com/v3/",
19+
"ApiKey": "[smtp2go api key goes here]",
20+
"Sender": "donotreply@devbetter.com"
2121
},
2222
"Logging": {
2323
"ApplicationInsights": {

tests/DevBetterWeb.Tests/Services/EmailServiceTests/Smtp2GoEmailServiceTests.cs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,6 @@ public void Constructor_WithNullOptions_ThrowsArgumentNullException()
1414
Assert.Throws<ArgumentNullException>(() => new Smtp2GoEmailService(null!));
1515
}
1616

17-
[Fact]
18-
public async Task SendEmailAsync_WithNullSmtpServer_ThrowsException()
19-
{
20-
var options = new AuthMessageSenderOptions();
21-
var service = new Smtp2GoEmailService(Options.Create(options));
22-
23-
var exception = await Assert.ThrowsAsync<Exception>(() =>
24-
service.SendEmailAsync("test@example.com", "Test Subject", "Test Message"));
25-
26-
Assert.Equal("SMTP Server not set.", exception.Message);
27-
}
28-
2917
[Fact]
3018
public async Task SendEmailAsync_WithNullApiKey_ThrowsException()
3119
{

0 commit comments

Comments
 (0)