refactor: support all TLS/SSL versions
This commit is contained in:
parent
43bcc87ad0
commit
9dd35b7ff0
@ -1,4 +1,5 @@
|
|||||||
using System.Net.Mail;
|
using System.Net.Mail;
|
||||||
|
using System.Security.Authentication;
|
||||||
using MailKit.Security;
|
using MailKit.Security;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.Extensions.Primitives;
|
using Microsoft.Extensions.Primitives;
|
||||||
@ -95,6 +96,7 @@ public class ContactController : Controller
|
|||||||
destination = mailSection.GetSection("Destination").Value ?? string.Empty;
|
destination = mailSection.GetSection("Destination").Value ?? string.Empty;
|
||||||
|
|
||||||
var client = new SmtpClient();
|
var client = new SmtpClient();
|
||||||
|
client.SslProtocols = SslProtocols.Ssl3 | SslProtocols.Tls | SslProtocols.Tls11 | SslProtocols.Tls12 | SslProtocols.Tls13;
|
||||||
client.ServerCertificateValidationCallback = (s, c, h, e) => true;
|
client.ServerCertificateValidationCallback = (s, c, h, e) => true;
|
||||||
client.Connect(mailServer, port, SecureSocketOptions.SslOnConnect);
|
client.Connect(mailServer, port, SecureSocketOptions.SslOnConnect);
|
||||||
client.Authenticate(mailUsername, mailPassword);
|
client.Authenticate(mailUsername, mailPassword);
|
||||||
|
Loading…
Reference in New Issue
Block a user