Skip to content
This repository was archived by the owner on Sep 23, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,22 @@ private void EnsureOptions()

if (string.IsNullOrWhiteSpace(_smtpOptions.Server))
throw new SmtpOptionsException(nameof(_smtpOptions.Server));

if (string.IsNullOrWhiteSpace(_smtpOptions.UserName))
throw new SmtpOptionsException(nameof(_smtpOptions.UserName));

if (string.IsNullOrWhiteSpace(_smtpOptions.Password))
throw new SmtpOptionsException(nameof(_smtpOptions.Password));
}

private async Task SendEmailMessageAsync(MimeMessage message)
{
using (var client = new SmtpClient())
{
client.LocalDomain = _smtpOptions.LocalDomain;
await client.ConnectAsync(_smtpOptions.Server, _smtpOptions.Port, SecureSocketOptions.None);
client.SslProtocols = System.Security.Authentication.SslProtocols.Tls12;

await client.ConnectAsync(_smtpOptions.Server, _smtpOptions.Port, SecureSocketOptions.StartTls);
client.Authenticate(_smtpOptions.UserName, _smtpOptions.Password);
await client.SendAsync(message);
await client.DisconnectAsync(true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,6 @@ public sealed class SmtpOptions
public string Server { get; set; }
public int Port { get; set; } = 25;
public string LocalDomain { get; set; }
public string UserName { get; set; }
public string Password { get; set; }
}