Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/Senders/FluentEmail.MailKit/MailKitSender.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using MimeKit;
using System;
using System.IO;
using System.Net.Security;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
Expand Down Expand Up @@ -54,6 +55,12 @@ public SendResponse Send(IFluentEmail email, CancellationToken? token = null)

using (var client = new SmtpClient())
{
client.CheckCertificateRevocation = _smtpClientOptions.CheckCertificateRevocation;
if(_smtpClientOptions.ServerCertificateValidationCallback != null)
{
client.ServerCertificateValidationCallback = _smtpClientOptions.ServerCertificateValidationCallback;
}

if (_smtpClientOptions.SocketOptions.HasValue)
{
client.Connect(
Expand Down Expand Up @@ -116,6 +123,12 @@ public async Task<SendResponse> SendAsync(IFluentEmail email, CancellationToken?

using (var client = new SmtpClient())
{
client.CheckCertificateRevocation = _smtpClientOptions.CheckCertificateRevocation;
if (_smtpClientOptions.ServerCertificateValidationCallback != null)
{
client.ServerCertificateValidationCallback = _smtpClientOptions.ServerCertificateValidationCallback;
}

if (_smtpClientOptions.SocketOptions.HasValue)
{
await client.ConnectAsync(
Expand Down
3 changes: 3 additions & 0 deletions src/Senders/FluentEmail.MailKit/SmtpClientOptions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using MailKit.Security;
using System.Net.Security;

namespace FluentEmail.MailKitSmtp
{
Expand All @@ -14,5 +15,7 @@ public class SmtpClientOptions
public bool UsePickupDirectory { get; set; } = false;
public string MailPickupDirectory { get; set; } = string.Empty;
public SecureSocketOptions? SocketOptions { get; set; }
public bool CheckCertificateRevocation { get; set; } = true;
public RemoteCertificateValidationCallback ServerCertificateValidationCallback { get; set; }
}
}