Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ GetConnection()

void System.Net.Mail.SmtpConnection.GetConnection ( string host,
int port )
inlinepackage

Definition at line 682 of file SmtpConnection.cs.

683 {
684 if (_isConnected)
685 {
687 }
688 InitializeConnection(host, port);
689 _responseReader = new SmtpReplyReaderFactory(_networkStream);
690 LineInfo lineInfo = _responseReader.GetNextReplyReader().ReadLine();
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 {
698 _extensions = EHelloCommand.Send(this, _client._clientDomain);
700 }
701 catch (SmtpException ex)
702 {
703 if (ex.StatusCode != SmtpStatusCode.CommandUnrecognized && ex.StatusCode != SmtpStatusCode.CommandNotImplemented)
704 {
705 throw;
706 }
707 HelloCommand.Send(this, _client._clientDomain);
708 _supportedAuth = SupportedAuth.Login;
709 }
710 if (_enableSsl)
711 {
713 {
714 throw new SmtpException(System.SR.MailServerDoesNotSupportStartTls);
715 }
716 StartTlsCommand.Send(this);
718 tlsStream.AuthenticateAsClient();
719 _networkStream = tlsStream;
720 _responseReader = new SmtpReplyReaderFactory(_networkStream);
721 _extensions = EHelloCommand.Send(this, _client._clientDomain);
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 {
752 throw new SmtpException(System.SR.SmtpAuthenticationFailed);
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 }
readonly ICredentialsByHost _credentials
void ParseExtensions(string[] extensions)
bool AuthSupported(ISmtpAuthenticationModule module)
Authorization SetContextAndTryAuthenticate(ISmtpAuthenticationModule module, NetworkCredential credential, System.Net.ContextAwareResult context)
SmtpReplyReaderFactory _responseReader
readonly ISmtpAuthenticationModule[] _authenticationModules
X509CertificateCollection _clientCertificates
void InitializeConnection(string host, int port)
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
NetworkCredential? GetCredential(string host, int port, string authenticationType)
void CloseContext(object sessionCookie)
Authorization Authenticate(string challenge, NetworkCredential credentials, object sessionCookie, string spn, ChannelBinding channelBindingToken)
SmtpStatusCode StatusCode
Definition LineInfo.cs:11

References System.Net.Mail.SmtpConnection._authenticationModules, System.Net.Mail.SmtpConnection._client, System.Net.Mail.SmtpConnection._clientCertificates, System.Net.Mail.SmtpClient._clientDomain, System.Net.Mail.SmtpConnection._credentials, System.Net.Mail.SmtpConnection._enableSsl, System.Net.Mail.SmtpConnection._extensions, System.Net.Mail.SmtpConnection._isConnected, System.Net.Mail.SmtpConnection._networkStream, System.Net.Mail.SmtpConnection._responseReader, System.Net.Mail.SmtpConnection._serverSupportsStartTls, System.Net.Mail.SmtpConnection._supportedAuth, System.Net.Mail.SmtpConnection._tcpClient, System.Net.Mail.ISmtpAuthenticationModule.Authenticate(), System.Net.TlsStream.AuthenticateAsClient(), System.Net.Mail.SmtpConnection.AuthSupported(), System.Net.Sockets.TcpClient.Client, System.Net.Mail.ISmtpAuthenticationModule.CloseContext(), System.Net.ICredentialsByHost.GetCredential(), System.Net.Mail.SmtpReplyReaderFactory.GetNextReplyReader(), System.Net.Mail.SmtpConnection.InitializeConnection(), System.Net.Mail.LineInfo.Line, System.SR.MailServerDoesNotSupportStartTls, System.Net.Authorization.Message, System.Net.Mail.SmtpConnection.ParseExtensions(), System.Net.Mail.SmtpReplyReader.ReadLine(), System.Net.Mail.StartTlsCommand.Send(), System.Net.Mail.EHelloCommand.Send(), System.Net.Mail.HelloCommand.Send(), System.Net.Mail.AuthCommand.Send(), System.Net.Mail.SmtpConnection.SetContextAndTryAuthenticate(), System.SR.SmtpAlreadyConnected, System.SR.SmtpAuthenticationFailed, System.Net.Mail.LineInfo.StatusCode, System.Net.Mail.SmtpException.StatusCode, and System.Net.Mail.SmtpClient.TargetName.

Referenced by System.Net.Mail.SmtpTransport.GetConnection().