修改查询bug
This commit is contained in:
@@ -30,5 +30,43 @@ public static class SendEmailHelper
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task SendEmailAsync(MimeMessage messageToSend, SMTPEmailConfig sMTPEmailConfig, EventHandler<MessageSentEventArgs>? 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(sMTPEmailConfig.Host, sMTPEmailConfig.Port, SecureSocketOptions.SslOnConnect);
|
||||
|
||||
await smtp.AuthenticateAsync(sMTPEmailConfig.UserName, sMTPEmailConfig.AuthorizationCode);
|
||||
|
||||
await smtp.SendAsync(messageToSend);
|
||||
|
||||
await smtp.DisconnectAsync(true);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public class SMTPEmailConfig
|
||||
{
|
||||
public int Port { get; set; }
|
||||
|
||||
public string Host { get; set; }
|
||||
|
||||
|
||||
public string UserName { get; set; }
|
||||
|
||||
public string AuthorizationCode { get; set; }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user