88using System . Text ;
99using System . Threading ;
1010using System . Threading . Tasks ;
11+ using MailKit ;
1112
1213namespace FluentEmail . MailKitSmtp
1314{
@@ -17,6 +18,7 @@ namespace FluentEmail.MailKitSmtp
1718 public class MailKitSender : ISender
1819 {
1920 private readonly SmtpClientOptions _smtpClientOptions ;
21+ private readonly IProtocolLogger _protocolLogger ;
2022
2123 /// <summary>
2224 /// Creates a sender that uses the given SmtpClientOptions when sending with MailKit. Since the client is internal this will dispose of the client.
@@ -27,6 +29,12 @@ public MailKitSender(SmtpClientOptions smtpClientOptions)
2729 _smtpClientOptions = smtpClientOptions ;
2830 }
2931
32+ public MailKitSender ( SmtpClientOptions smtpClientOptions , IProtocolLogger protocolLogger )
33+ {
34+ _smtpClientOptions = smtpClientOptions ;
35+ _protocolLogger = protocolLogger ;
36+ }
37+
3038 /// <summary>
3139 /// Send the specified email.
3240 /// </summary>
@@ -52,7 +60,7 @@ public SendResponse Send(IFluentEmail email, CancellationToken? token = null)
5260 return response ;
5361 }
5462
55- using ( var client = new SmtpClient ( ) )
63+ using ( var client = _protocolLogger == null ? new SmtpClient ( ) : new SmtpClient ( _protocolLogger ) )
5664 {
5765 if ( _smtpClientOptions . SocketOptions . HasValue )
5866 {
@@ -115,7 +123,7 @@ public async Task<SendResponse> SendAsync(IFluentEmail email, CancellationToken?
115123 return response ;
116124 }
117125
118- using ( var client = new SmtpClient ( ) )
126+ using ( var client = _protocolLogger == null ? new SmtpClient ( ) : new SmtpClient ( _protocolLogger ) )
119127 {
120128 if ( _smtpClientOptions . SocketOptions . HasValue )
121129 {
0 commit comments