update infra docs

This commit is contained in:
Aaron Po
2026-08-04 06:18:54 -04:00
parent 88abb8e995
commit 64302286fb
11 changed files with 21 additions and 151 deletions

View File

@@ -5,21 +5,7 @@ namespace Infrastructure.Email;
/// </summary>
public interface IEmailProvider
{
/// <summary>
/// Sends an email to a single recipient.
/// </summary>
/// <param name="to">Recipient email address</param>
/// <param name="subject">Email subject line</param>
/// <param name="body">Email body (HTML or plain text)</param>
/// <param name="isHtml">Whether the body is HTML (default: true)</param>
Task SendAsync(string to, string subject, string body, bool isHtml = true);
/// <summary>
/// Sends an email to multiple recipients.
/// </summary>
/// <param name="to">List of recipient email addresses</param>
/// <param name="subject">Email subject line</param>
/// <param name="body">Email body (HTML or plain text)</param>
/// <param name="isHtml">Whether the body is HTML (default: true)</param>
Task SendAsync(IEnumerable<string> to, string subject, string body, bool isHtml = true);
}

View File

@@ -19,38 +19,10 @@ public class SmtpEmailProvider : IEmailProvider
private readonly bool _useSsl;
/// <summary>
/// Initializes a new instance of <see cref="SmtpEmailProvider" />, reading SMTP configuration
/// from environment variables.
/// Initializes a new instance of the <see cref="SmtpEmailProvider" /> class, reading SMTP configuration
/// from environment variables (<c>SMTP_HOST</c>, <c>SMTP_PORT</c>, <c>SMTP_USERNAME</c>,
/// <c>SMTP_PASSWORD</c>, <c>SMTP_USE_SSL</c>, <c>SMTP_FROM_EMAIL</c>, <c>SMTP_FROM_NAME</c>).
/// </summary>
/// <remarks>
/// Reads the following environment variables:
/// <list type="bullet">
/// <item>
/// <description><c>SMTP_HOST</c> (required) - the SMTP server hostname.</description>
/// </item>
/// <item>
/// <description><c>SMTP_PORT</c> (optional, default "587") - the SMTP server port, must be a valid integer.</description>
/// </item>
/// <item>
/// <description><c>SMTP_USERNAME</c> (optional) - the username used for authentication.</description>
/// </item>
/// <item>
/// <description><c>SMTP_PASSWORD</c> (optional) - the password used for authentication.</description>
/// </item>
/// <item>
/// <description><c>SMTP_USE_SSL</c> (optional, default "true") - whether to use StartTls when connecting.</description>
/// </item>
/// <item>
/// <description><c>SMTP_FROM_EMAIL</c> (required) - the email address used as the sender.</description>
/// </item>
/// <item>
/// <description>
/// <c>SMTP_FROM_NAME</c> (optional, default "The Biergarten") - the display name used as the
/// sender.
/// </description>
/// </item>
/// </list>
/// </remarks>
/// <exception cref="InvalidOperationException">
/// Thrown when <c>SMTP_HOST</c> or <c>SMTP_FROM_EMAIL</c> is not set, or when <c>SMTP_PORT</c> is not a valid integer.
/// </exception>
@@ -79,31 +51,17 @@ public class SmtpEmailProvider : IEmailProvider
_fromName = Environment.GetEnvironmentVariable("SMTP_FROM_NAME") ?? "The Biergarten";
}
/// <summary>
/// Sends an email to a single recipient by delegating to the multi-recipient overload.
/// </summary>
/// <param name="to">Recipient email address</param>
/// <param name="subject">Email subject line</param>
/// <param name="body">Email body (HTML or plain text)</param>
/// <param name="isHtml">Whether the body is HTML (default: true)</param>
/// <exception cref="InvalidOperationException">Thrown when connecting, authenticating, or sending via SMTP fails.</exception>
public async Task SendAsync(string to, string subject, string body, bool isHtml = true)
{
await SendAsync([to], subject, body, isHtml);
}
/// <summary>
/// Sends an email to multiple recipients using MailKit's <see cref="SmtpClient" />.
/// Connects using StartTls when SSL is enabled (or no encryption otherwise), authenticates
/// if credentials were configured, sends the message, and disconnects.
/// </summary>
/// <param name="to">List of recipient email addresses</param>
/// <param name="subject">Email subject line</param>
/// <param name="body">Email body (HTML or plain text)</param>
/// <param name="isHtml">Whether the body is HTML (default: true)</param>
/// <exception cref="InvalidOperationException">
/// Thrown when connecting, authenticating, or sending via SMTP fails. The
/// original exception is included as the inner exception.
/// Thrown when connecting, authenticating, or sending via SMTP fails, wrapping the original exception.
/// </exception>
public async Task SendAsync(
IEnumerable<string> to,