Skip to content

Commit a4a4ab5

Browse files
committed
merge
1 parent d43fd2e commit a4a4ab5

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/DevBetterWeb.Infrastructure/Services/Smtp2GoEmailService.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,20 @@ public Smtp2GoEmailService(IOptions<ApiMailSenderOptions> optionsAccessor)
2020
_httpClient = new HttpClient();
2121
}
2222

23-
24-
public async Task SendEmailAsync(string email, string subject, string message)
23+
public ApiMailSenderOptions Options { get; }
24+
public async Task SendEmailAsync(string email, string subject, string message)
2525
{
2626
if (string.IsNullOrEmpty(Options.ApiKey)) throw new Exception("SMTP API Key not set.");
2727
if (string.IsNullOrEmpty(Options.ApiBaseUrl)) throw new Exception("SMTP API Base URL not set.");
2828
if (string.IsNullOrEmpty(Options.Sender)) throw new Exception("SMTP Sender not set.");
2929

30-
request.Headers.Add("Authorization", $"Bearer {Options.ApiKey}");
30+
var request = new HttpRequestMessage(HttpMethod.Post, Options.ApiBaseUrl.TrimEnd('/') + "/email/send");
31+
request.Headers.Add("Authorization", $"Bearer {Options.ApiKey}");
3132

3233
var payload = new
3334
{
34-
to = new[] { email },
35+
sender = Options.Sender,
36+
to = new[] { email },
3537
subject = subject,
3638
text_body = message,
3739
html_body = message

0 commit comments

Comments
 (0)