Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
SmtpConnection.cs
Go to the documentation of this file.
1using System.IO;
7
8namespace System.Net.Mail;
9
10internal sealed class SmtpConnection
11{
12 private sealed class AuthenticateCallbackContext
13 {
14 internal readonly SmtpConnection _thisPtr;
15
17
18 internal readonly NetworkCredential _credential;
19
20 internal readonly string _spn;
21
22 internal readonly ChannelBinding _token;
23
25
27 {
28 _thisPtr = thisPtr;
29 _module = module;
30 _credential = credential;
31 _spn = spn;
32 _token = Token;
33 _result = null;
34 }
35 }
36
38 {
39 private string _authResponse;
40
41 private readonly SmtpConnection _connection;
42
43 private int _currentModule = -1;
44
45 private readonly int _port;
46
47 private static readonly AsyncCallback s_handshakeCallback = HandshakeCallback;
48
49 private static readonly AsyncCallback s_sendEHelloCallback = SendEHelloCallback;
50
51 private static readonly AsyncCallback s_sendHelloCallback = SendHelloCallback;
52
53 private static readonly AsyncCallback s_authenticateCallback = AuthenticateCallback;
54
55 private static readonly AsyncCallback s_authenticateContinueCallback = AuthenticateContinueCallback;
56
57 private readonly string _host;
58
60
61 internal ConnectAndHandshakeAsyncResult(SmtpConnection connection, string host, int port, System.Net.ContextAwareResult outerResult, AsyncCallback callback, object state)
62 : base(null, state, callback)
63 {
64 _connection = connection;
65 _host = host;
66 _port = port;
67 _outerResult = outerResult;
68 }
69
70 internal static void End(IAsyncResult result)
71 {
72 ConnectAndHandshakeAsyncResult connectAndHandshakeAsyncResult = (ConnectAndHandshakeAsyncResult)result;
73 object obj = connectAndHandshakeAsyncResult.InternalWaitForCompletion();
74 if (obj is Exception source)
75 {
77 }
78 }
79
88
89 private void InitializeConnection()
90 {
92 if (!asyncResult.CompletedSynchronously)
93 {
94 return;
95 }
96 try
97 {
99 if (System.Net.NetEventSource.Log.IsEnabled())
100 {
101 System.Net.NetEventSource.Info(this, "Connect returned", "InitializeConnection");
102 }
103 Handshake();
104 }
105 catch (Exception result)
106 {
107 InvokeCallback(result);
108 }
109 }
110
111 private static void InitializeConnectionCallback(IAsyncResult result)
112 {
113 if (result.CompletedSynchronously)
114 {
115 return;
116 }
117 ConnectAndHandshakeAsyncResult connectAndHandshakeAsyncResult = (ConnectAndHandshakeAsyncResult)result.AsyncState;
118 try
119 {
120 connectAndHandshakeAsyncResult._connection.EndInitializeConnection(result);
121 if (System.Net.NetEventSource.Log.IsEnabled())
122 {
123 System.Net.NetEventSource.Info(null, $"Connect returned {connectAndHandshakeAsyncResult}", "InitializeConnectionCallback");
124 }
125 connectAndHandshakeAsyncResult.Handshake();
126 }
127 catch (Exception result2)
128 {
129 connectAndHandshakeAsyncResult.InvokeCallback(result2);
130 }
131 }
132
133 private void Handshake()
134 {
135 _connection._responseReader = new SmtpReplyReaderFactory(_connection._networkStream);
138 if (!asyncResult.CompletedSynchronously)
139 {
140 return;
141 }
142 LineInfo lineInfo = nextReplyReader.EndReadLine(asyncResult);
143 if (lineInfo.StatusCode != SmtpStatusCode.ServiceReady)
144 {
145 throw new SmtpException(lineInfo.StatusCode, lineInfo.Line, serverResponse: true);
146 }
147 try
148 {
149 SendEHello();
150 }
151 catch
152 {
153 SendHello();
154 }
155 }
156
157 private static void HandshakeCallback(IAsyncResult result)
158 {
159 if (result.CompletedSynchronously)
160 {
161 return;
162 }
163 ConnectAndHandshakeAsyncResult connectAndHandshakeAsyncResult = (ConnectAndHandshakeAsyncResult)result.AsyncState;
164 try
165 {
166 try
167 {
168 LineInfo lineInfo = connectAndHandshakeAsyncResult._connection.Reader.CurrentReader.EndReadLine(result);
169 if (lineInfo.StatusCode != SmtpStatusCode.ServiceReady)
170 {
171 connectAndHandshakeAsyncResult.InvokeCallback(new SmtpException(lineInfo.StatusCode, lineInfo.Line, serverResponse: true));
172 }
173 else if (connectAndHandshakeAsyncResult.SendEHello())
174 {
175 }
176 }
177 catch (SmtpException)
178 {
179 if (connectAndHandshakeAsyncResult.SendHello())
180 {
181 }
182 }
183 }
184 catch (Exception result2)
185 {
186 connectAndHandshakeAsyncResult.InvokeCallback(result2);
187 }
188 }
189
190 private bool SendEHello()
191 {
193 if (asyncResult.CompletedSynchronously)
194 {
195 _connection._extensions = EHelloCommand.EndSend(asyncResult);
198 {
199 Authenticate();
200 return true;
201 }
203 {
205 {
207 }
208 SendStartTls();
209 }
210 else
211 {
212 Authenticate();
213 }
214 return true;
215 }
216 return false;
217 }
218
219 private static void SendEHelloCallback(IAsyncResult result)
220 {
221 if (result.CompletedSynchronously)
222 {
223 return;
224 }
225 ConnectAndHandshakeAsyncResult connectAndHandshakeAsyncResult = (ConnectAndHandshakeAsyncResult)result.AsyncState;
226 try
227 {
228 try
229 {
230 connectAndHandshakeAsyncResult._connection._extensions = EHelloCommand.EndSend(result);
231 connectAndHandshakeAsyncResult._connection.ParseExtensions(connectAndHandshakeAsyncResult._connection._extensions);
232 if (connectAndHandshakeAsyncResult._connection._networkStream is System.Net.TlsStream)
233 {
234 connectAndHandshakeAsyncResult.Authenticate();
235 return;
236 }
237 }
238 catch (SmtpException ex)
239 {
240 if (ex.StatusCode != SmtpStatusCode.CommandUnrecognized && ex.StatusCode != SmtpStatusCode.CommandNotImplemented)
241 {
242 throw;
243 }
244 if (!connectAndHandshakeAsyncResult.SendHello())
245 {
246 return;
247 }
248 }
249 if (connectAndHandshakeAsyncResult._connection.EnableSsl)
250 {
251 if (!connectAndHandshakeAsyncResult._connection._serverSupportsStartTls && !(connectAndHandshakeAsyncResult._connection._networkStream is System.Net.TlsStream))
252 {
254 }
255 connectAndHandshakeAsyncResult.SendStartTls();
256 }
257 else
258 {
259 connectAndHandshakeAsyncResult.Authenticate();
260 }
261 }
262 catch (Exception result2)
263 {
264 connectAndHandshakeAsyncResult.InvokeCallback(result2);
265 }
266 }
267
268 private bool SendHello()
269 {
271 if (asyncResult.CompletedSynchronously)
272 {
273 _connection._supportedAuth = SupportedAuth.Login;
275 Authenticate();
276 return true;
277 }
278 return false;
279 }
280
281 private static void SendHelloCallback(IAsyncResult result)
282 {
283 if (!result.CompletedSynchronously)
284 {
285 ConnectAndHandshakeAsyncResult connectAndHandshakeAsyncResult = (ConnectAndHandshakeAsyncResult)result.AsyncState;
286 try
287 {
288 HelloCommand.EndSend(result);
289 connectAndHandshakeAsyncResult.Authenticate();
290 }
291 catch (Exception result2)
292 {
293 connectAndHandshakeAsyncResult.InvokeCallback(result2);
294 }
295 }
296 }
297
298 private bool SendStartTls()
299 {
301 if (asyncResult.CompletedSynchronously)
302 {
305 return true;
306 }
307 return false;
308 }
309
310 private static void SendStartTlsCallback(IAsyncResult result)
311 {
312 if (!result.CompletedSynchronously)
313 {
314 ConnectAndHandshakeAsyncResult connectAndHandshakeAsyncResult = (ConnectAndHandshakeAsyncResult)result.AsyncState;
315 try
316 {
317 StartTlsCommand.EndSend(result);
318 connectAndHandshakeAsyncResult.TlsStreamAuthenticate();
319 }
320 catch (Exception result2)
321 {
322 connectAndHandshakeAsyncResult.InvokeCallback(result2);
323 }
324 }
325 }
326
328 {
331 if (asyncResult.CompletedSynchronously)
332 {
333 ((System.Net.TlsStream)_connection._networkStream).EndAuthenticateAsClient(asyncResult);
334 _connection._responseReader = new SmtpReplyReaderFactory(_connection._networkStream);
335 SendEHello();
336 return true;
337 }
338 return false;
339 }
340
341 private static void TlsStreamAuthenticateCallback(IAsyncResult result)
342 {
343 if (!result.CompletedSynchronously)
344 {
345 ConnectAndHandshakeAsyncResult connectAndHandshakeAsyncResult = (ConnectAndHandshakeAsyncResult)result.AsyncState;
346 try
347 {
348 (connectAndHandshakeAsyncResult._connection._networkStream as System.Net.TlsStream).EndAuthenticateAsClient(result);
349 connectAndHandshakeAsyncResult._connection._responseReader = new SmtpReplyReaderFactory(connectAndHandshakeAsyncResult._connection._networkStream);
350 connectAndHandshakeAsyncResult.SendEHello();
351 }
352 catch (Exception result2)
353 {
354 connectAndHandshakeAsyncResult.InvokeCallback(result2);
355 }
356 }
357 }
358
359 private void Authenticate()
360 {
361 if (_connection._credentials != null)
362 {
364 {
366 if (!_connection.AuthSupported(smtpAuthenticationModule))
367 {
368 continue;
369 }
371 if (credential == null)
372 {
373 continue;
374 }
375 Authorization authorization = _connection.SetContextAndTryAuthenticate(smtpAuthenticationModule, credential, _outerResult);
376 if (authorization == null || authorization.Message == null)
377 {
378 continue;
379 }
381 if (!asyncResult.CompletedSynchronously)
382 {
383 return;
384 }
386 if (lineInfo.StatusCode == (SmtpStatusCode)334)
387 {
388 _authResponse = lineInfo.Line;
390 {
391 return;
392 }
393 }
394 else if (lineInfo.StatusCode == (SmtpStatusCode)235)
395 {
396 smtpAuthenticationModule.CloseContext(_connection);
397 _connection._isConnected = true;
398 break;
399 }
400 }
401 }
402 _connection._isConnected = true;
404 }
405
406 private static void AuthenticateCallback(IAsyncResult result)
407 {
408 if (result.CompletedSynchronously)
409 {
410 return;
411 }
412 ConnectAndHandshakeAsyncResult connectAndHandshakeAsyncResult = (ConnectAndHandshakeAsyncResult)result.AsyncState;
413 try
414 {
415 LineInfo lineInfo = AuthCommand.EndSend(result);
416 if (lineInfo.StatusCode == (SmtpStatusCode)334)
417 {
418 connectAndHandshakeAsyncResult._authResponse = lineInfo.Line;
419 if (!connectAndHandshakeAsyncResult.AuthenticateContinue())
420 {
421 return;
422 }
423 }
424 else if (lineInfo.StatusCode == (SmtpStatusCode)235)
425 {
426 connectAndHandshakeAsyncResult._connection._authenticationModules[connectAndHandshakeAsyncResult._currentModule].CloseContext(connectAndHandshakeAsyncResult._connection);
427 connectAndHandshakeAsyncResult._connection._isConnected = true;
428 connectAndHandshakeAsyncResult.InvokeCallback();
429 return;
430 }
431 connectAndHandshakeAsyncResult.Authenticate();
432 }
433 catch (Exception result2)
434 {
435 connectAndHandshakeAsyncResult.InvokeCallback(result2);
436 }
437 }
438
439 private bool AuthenticateContinue()
440 {
441 while (true)
442 {
444 if (authorization == null)
445 {
447 }
449 if (!asyncResult.CompletedSynchronously)
450 {
451 return false;
452 }
454 if (lineInfo.StatusCode == (SmtpStatusCode)235)
455 {
457 _connection._isConnected = true;
459 return false;
460 }
461 if (lineInfo.StatusCode != (SmtpStatusCode)334)
462 {
463 break;
464 }
465 _authResponse = lineInfo.Line;
466 }
467 return true;
468 }
469
470 private static void AuthenticateContinueCallback(IAsyncResult result)
471 {
472 if (result.CompletedSynchronously)
473 {
474 return;
475 }
476 ConnectAndHandshakeAsyncResult connectAndHandshakeAsyncResult = (ConnectAndHandshakeAsyncResult)result.AsyncState;
477 try
478 {
479 LineInfo lineInfo = AuthCommand.EndSend(result);
480 if (lineInfo.StatusCode == (SmtpStatusCode)235)
481 {
482 connectAndHandshakeAsyncResult._connection._authenticationModules[connectAndHandshakeAsyncResult._currentModule].CloseContext(connectAndHandshakeAsyncResult._connection);
483 connectAndHandshakeAsyncResult._connection._isConnected = true;
484 connectAndHandshakeAsyncResult.InvokeCallback();
485 return;
486 }
487 if (lineInfo.StatusCode == (SmtpStatusCode)334)
488 {
489 connectAndHandshakeAsyncResult._authResponse = lineInfo.Line;
490 if (!connectAndHandshakeAsyncResult.AuthenticateContinue())
491 {
492 return;
493 }
494 }
495 connectAndHandshakeAsyncResult.Authenticate();
496 }
497 catch (Exception result2)
498 {
499 connectAndHandshakeAsyncResult.InvokeCallback(result2);
500 }
501 }
502 }
503
505
507
508 private bool _isConnected;
509
510 private bool _isClosed;
511
512 private bool _isStreamOpen;
513
514 private readonly EventHandler _onCloseHandler;
515
517
518 private readonly SmtpClient _client;
519
521
523
525
527
528 private string[] _extensions;
529
530 private bool _enableSsl;
531
533
534 private bool _serverSupportsEai;
535
536 private bool _dsnEnabled;
537
539
540 private bool _sawNegotiate;
541
543
545
546 private static readonly char[] s_authExtensionSplitters = new char[2] { ' ', '=' };
547
549
550 internal bool IsConnected => _isConnected;
551
552 internal bool IsStreamOpen => _isStreamOpen;
553
555
556 internal bool EnableSsl
557 {
558 get
559 {
560 return _enableSsl;
561 }
562 set
563 {
565 }
566 }
567
569 {
570 set
571 {
573 }
574 }
575
576 internal bool DSNEnabled => _dsnEnabled;
577
579
580 internal SmtpConnection(SmtpTransport parent, SmtpClient client, ICredentialsByHost credentials, ISmtpAuthenticationModule[] authenticationModules)
581 {
582 _client = client;
583 _credentials = credentials;
584 _authenticationModules = authenticationModules;
585 _parent = parent;
586 _tcpClient = new TcpClient();
588 }
589
590 internal void InitializeConnection(string host, int port)
591 {
592 _tcpClient.Connect(host, port);
594 }
595
596 internal IAsyncResult BeginInitializeConnection(string host, int port, AsyncCallback callback, object state)
597 {
598 return _tcpClient.BeginConnect(host, port, callback, state);
599 }
600
602 {
603 _tcpClient.EndConnect(result);
605 }
606
607 internal IAsyncResult BeginGetConnection(System.Net.ContextAwareResult outerResult, AsyncCallback callback, object state, string host, int port)
608 {
609 ConnectAndHandshakeAsyncResult connectAndHandshakeAsyncResult = new ConnectAndHandshakeAsyncResult(this, host, port, outerResult, callback, state);
610 connectAndHandshakeAsyncResult.GetConnection();
611 return connectAndHandshakeAsyncResult;
612 }
613
614 internal IAsyncResult BeginFlush(AsyncCallback callback, object state)
615 {
617 }
618
619 internal void EndFlush(IAsyncResult result)
620 {
621 _networkStream.EndWrite(result);
623 }
624
630
631 private void ShutdownConnection(bool isAbort)
632 {
633 if (!_isClosed)
634 {
635 lock (this)
636 {
637 if (!_isClosed && _tcpClient != null)
638 {
639 try
640 {
641 try
642 {
643 if (isAbort)
644 {
645 _tcpClient.LingerState = new LingerOption(enable: true, 0);
646 }
647 else
648 {
649 _tcpClient.Client.Blocking = false;
650 QuitCommand.Send(this);
651 }
652 }
653 finally
654 {
657 }
658 }
659 catch (IOException)
660 {
661 }
663 {
664 }
665 }
666 _isClosed = true;
667 }
668 }
669 _isConnected = false;
670 }
671
672 internal void ReleaseConnection()
673 {
674 ShutdownConnection(isAbort: false);
675 }
676
677 internal void Abort()
678 {
679 ShutdownConnection(isAbort: true);
680 }
681
682 internal void GetConnection(string host, int port)
683 {
684 if (_isConnected)
685 {
687 }
688 InitializeConnection(host, port);
691 SmtpStatusCode statusCode = lineInfo.StatusCode;
692 if (statusCode != SmtpStatusCode.ServiceReady)
693 {
694 throw new SmtpException(lineInfo.StatusCode, lineInfo.Line, serverResponse: true);
695 }
696 try
697 {
700 }
701 catch (SmtpException ex)
702 {
703 if (ex.StatusCode != SmtpStatusCode.CommandUnrecognized && ex.StatusCode != SmtpStatusCode.CommandNotImplemented)
704 {
705 throw;
706 }
709 }
710 if (_enableSsl)
711 {
713 {
715 }
716 StartTlsCommand.Send(this);
718 tlsStream.AuthenticateAsClient();
719 _networkStream = tlsStream;
723 }
724 if (_credentials != null)
725 {
726 for (int i = 0; i < _authenticationModules.Length; i++)
727 {
729 {
730 continue;
731 }
732 NetworkCredential credential = _credentials.GetCredential(host, port, _authenticationModules[i].AuthenticationType);
733 if (credential == null)
734 {
735 continue;
736 }
737 Authorization authorization = SetContextAndTryAuthenticate(_authenticationModules[i], credential, null);
738 if (authorization == null || authorization.Message == null)
739 {
740 continue;
741 }
742 lineInfo = AuthCommand.Send(this, _authenticationModules[i].AuthenticationType, authorization.Message);
743 if (lineInfo.StatusCode == SmtpStatusCode.CommandParameterNotImplemented)
744 {
745 continue;
746 }
747 while (lineInfo.StatusCode == (SmtpStatusCode)334)
748 {
749 authorization = _authenticationModules[i].Authenticate(lineInfo.Line, null, this, _client.TargetName, null);
750 if (authorization == null)
751 {
753 }
754 lineInfo = AuthCommand.Send(this, authorization.Message);
755 if (lineInfo.StatusCode == (SmtpStatusCode)235)
756 {
758 _isConnected = true;
759 return;
760 }
761 }
762 }
763 }
764 _isConnected = true;
765 }
766
768 {
770 {
771 try
772 {
773 ExecutionContext executionContext = context?.ContextCopy;
774 if (executionContext != null)
775 {
776 AuthenticateCallbackContext authenticateCallbackContext = new AuthenticateCallbackContext(this, module, credential, _client.TargetName, null);
777 ExecutionContext.Run(executionContext, s_AuthenticateCallback, authenticateCallbackContext);
778 return authenticateCallbackContext._result;
779 }
780 return module.Authenticate(null, credential, this, _client.TargetName, null);
781 }
782 catch
783 {
784 throw;
785 }
786 }
787 return module.Authenticate(null, credential, this, _client.TargetName, null);
788 }
789
790 private static void AuthenticateCallback(object state)
791 {
793 authenticateCallbackContext._result = authenticateCallbackContext._module.Authenticate(null, authenticateCallbackContext._credential, authenticateCallbackContext._thisPtr, authenticateCallbackContext._spn, authenticateCallbackContext._token);
794 }
795
796 internal void EndGetConnection(IAsyncResult result)
797 {
799 }
800
802 {
804 _isStreamOpen = true;
805 return result;
806 }
807
808 private void OnClose(object sender, EventArgs args)
809 {
810 _isStreamOpen = false;
811 DataStopCommand.Send(this);
812 }
813
814 internal void ParseExtensions(string[] extensions)
815 {
817 foreach (string text in extensions)
818 {
819 if (string.Compare(text, 0, "auth", 0, 4, StringComparison.OrdinalIgnoreCase) == 0)
820 {
821 string[] array = text.Remove(0, 4).Split(s_authExtensionSplitters, StringSplitOptions.RemoveEmptyEntries);
822 string[] array2 = array;
823 foreach (string a in array2)
824 {
825 if (string.Equals(a, "login", StringComparison.OrdinalIgnoreCase))
826 {
828 }
829 else if (string.Equals(a, "ntlm", StringComparison.OrdinalIgnoreCase))
830 {
832 }
833 else if (string.Equals(a, "gssapi", StringComparison.OrdinalIgnoreCase))
834 {
836 }
837 }
838 }
839 else if (string.Compare(text, 0, "dsn ", 0, 3, StringComparison.OrdinalIgnoreCase) == 0)
840 {
841 _dsnEnabled = true;
842 }
843 else if (string.Compare(text, 0, "STARTTLS", 0, 8, StringComparison.OrdinalIgnoreCase) == 0)
844 {
846 }
847 else if (string.Compare(text, 0, "SMTPUTF8", 0, 8, StringComparison.OrdinalIgnoreCase) == 0)
848 {
849 _serverSupportsEai = true;
850 }
851 }
852 }
853
855 {
856 if (module is SmtpLoginAuthenticationModule)
857 {
858 if ((_supportedAuth & SupportedAuth.Login) > SupportedAuth.None)
859 {
860 return true;
861 }
862 }
863 else if (module is SmtpNegotiateAuthenticationModule)
864 {
865 if ((_supportedAuth & SupportedAuth.GSSAPI) > SupportedAuth.None)
866 {
867 _sawNegotiate = true;
868 return true;
869 }
870 }
872 {
873 return true;
874 }
875 return false;
876 }
877}
static NetworkCredential DefaultNetworkCredentials
void InvokeCallback(object result)
static LineInfo EndSend(IAsyncResult result)
static IAsyncResult BeginSend(SmtpConnection conn, string type, string message, AsyncCallback callback, object state)
Definition AuthCommand.cs:5
static LineInfo Send(SmtpConnection conn, string type, string message)
static void Send(SmtpConnection conn)
static string[] Send(SmtpConnection conn, string domain)
static string[] EndSend(IAsyncResult result)
static IAsyncResult BeginSend(SmtpConnection conn, string domain, AsyncCallback callback, object state)
static void Send(SmtpConnection conn, string domain)
static void EndSend(IAsyncResult result)
static IAsyncResult BeginSend(SmtpConnection conn, string domain, AsyncCallback callback, object state)
static void Send(SmtpConnection conn)
AuthenticateCallbackContext(SmtpConnection thisPtr, ISmtpAuthenticationModule module, NetworkCredential credential, string spn, ChannelBinding Token)
ConnectAndHandshakeAsyncResult(SmtpConnection connection, string host, int port, System.Net.ContextAwareResult outerResult, AsyncCallback callback, object state)
void OnClose(object sender, EventArgs args)
readonly ICredentialsByHost _credentials
static readonly ContextCallback s_AuthenticateCallback
readonly BufferBuilder _bufferBuilder
SmtpReplyReaderFactory Reader
void ParseExtensions(string[] extensions)
SmtpConnection(SmtpTransport parent, SmtpClient client, ICredentialsByHost credentials, ISmtpAuthenticationModule[] authenticationModules)
IAsyncResult BeginInitializeConnection(string host, int port, AsyncCallback callback, object state)
void EndFlush(IAsyncResult result)
IAsyncResult BeginFlush(AsyncCallback callback, object state)
IAsyncResult BeginGetConnection(System.Net.ContextAwareResult outerResult, AsyncCallback callback, object state, string host, int port)
readonly EventHandler _onCloseHandler
bool AuthSupported(ISmtpAuthenticationModule module)
Authorization SetContextAndTryAuthenticate(ISmtpAuthenticationModule module, NetworkCredential credential, System.Net.ContextAwareResult context)
SmtpReplyReaderFactory _responseReader
void GetConnection(string host, int port)
static void AuthenticateCallback(object state)
readonly ISmtpAuthenticationModule[] _authenticationModules
X509CertificateCollection _clientCertificates
static readonly char[] s_authExtensionSplitters
void ShutdownConnection(bool isAbort)
X509CertificateCollection ClientCertificates
void EndGetConnection(IAsyncResult result)
void InitializeConnection(string host, int port)
void EndInitializeConnection(IAsyncResult result)
LineInfo EndReadLine(IAsyncResult result)
IAsyncResult BeginReadLine(AsyncCallback callback, object state)
static void Send(SmtpConnection conn)
static IAsyncResult BeginSend(SmtpConnection conn, AsyncCallback callback, object state)
static void EndSend(IAsyncResult result)
static readonly System.Net.NetEventSource Log
static void Info(object thisOrContextObject, FormattableString formattableString=null, [CallerMemberName] string memberName=null)
override void Write(byte[] buffer, int offset, int count)
override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback? callback, object? state)
override void EndWrite(IAsyncResult asyncResult)
IAsyncResult BeginConnect(IPAddress address, int port, AsyncCallback? requestCallback, object? state)
Definition TcpClient.cs:370
virtual void Dispose(bool disposing)
Definition TcpClient.cs:410
NetworkStream GetStream()
Definition TcpClient.cs:391
void EndConnect(IAsyncResult asyncResult)
Definition TcpClient.cs:385
void Connect(string hostname, int port)
Definition TcpClient.cs:209
void AuthenticateAsClient()
Definition TlsStream.cs:24
static string SmtpAlreadyConnected
Definition SR.cs:134
static string SmtpAuthenticationFailed
Definition SR.cs:136
static string MailServerDoesNotSupportStartTls
Definition SR.cs:168
Definition SR.cs:7
static void Run(ExecutionContext executionContext, ContextCallback callback, object? state)
NetworkCredential? GetCredential(string host, int port, string authenticationType)
void CloseContext(object sessionCookie)
Authorization Authenticate(string challenge, NetworkCredential credentials, object sessionCookie, string spn, ChannelBinding channelBindingToken)
delegate void ContextCallback(object? state)
SmtpStatusCode StatusCode
Definition LineInfo.cs:11