using MailKit; using MailKit.Security; using MimeKit; namespace IRaCIS.Core.Application.Helper; public static class SendEmailHelper { public static async Task SendEmailAsync(MimeMessage messageToSend, EventHandler? messageSentSuccess = null) { using (var smtp = new MailKit.Net.Smtp.SmtpClient()) { if (messageSentSuccess != null) { smtp.MessageSent += messageSentSuccess; } smtp.ServerCertificateValidationCallback = (s, c, h, e) => true; await smtp.ConnectAsync("smtp.163.com", 465, SecureSocketOptions.SslOnConnect); await smtp.AuthenticateAsync("iracis_grr@163.com", "XLWVQKZAEKLDWOAH"); await smtp.SendAsync(messageToSend); await smtp.DisconnectAsync(true); } } }