feat: email verification via smtp

This commit is contained in:
2026-03-06 20:10:07 -05:00
parent d21265f443
commit 95da3f9543
19 changed files with 773 additions and 3 deletions
@@ -0,0 +1,31 @@
using MailKit.Net.Smtp;
using MailKit.Security;
using Microsoft.Extensions.Options;
using MimeKit;
using SharpbinV3.Server.Settings;
namespace SharpbinV3.Server.Services
{
public class EmailService(IOptions<EmailSettings> emailSettings)
{
private readonly EmailSettings settings = emailSettings.Value;
public async Task SendAsync(string to, string subject, string body)
{
var message = new MimeMessage();
message.From.Add(new MailboxAddress("Sharpbin", settings.From));
message.To.Add(MailboxAddress.Parse(to));
message.Subject = subject;
message.Body = new TextPart("html") { Text = body };
using var smtp = new SmtpClient();
await smtp.ConnectAsync(settings.Host, settings.Port, SecureSocketOptions.StartTls);
await smtp.AuthenticateAsync(settings.User, settings.Password);
await smtp.SendAsync(message);
await smtp.DisconnectAsync(true);
}
}
}