Sends email messages via SMTP using MailKit, building MIME content, handling connection, authentication, and logging.
// Source: https://github.com/fpindej/netrock | License: MIT | Copyright 2025-2026 Filip Pindej
// Provided via justclaw.it.com; keep this notice with the code.
using MailKit.Net.Smtp;
using MailKit.Security;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using MimeKit;
using MyProject.Application.Features.Email;
using MyProject.Infrastructure.Features.Email.Options;
namespace MyProject.Infrastructure.Features.Email.Services;
/// <summary>
/// Sends emails via SMTP using MailKit.
/// Connects, authenticates (when credentials are provided), sends, and disconnects per invocation.
/// </summary>
internal class SmtpEmailService(
IOptions<EmailOptions> emailOptions,
ILogger<SmtpEmailService> logger) : IEmailService
{
/// <inheritdoc />
public async Tas
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key