System.Net.Mail.SmtpConnection.ParseExtensions C# (CSharp) Method

ParseExtensions() private method

private ParseExtensions ( string extensions ) : void
extensions string
return void
        internal void ParseExtensions(string[] extensions)
        {
            _supportedAuth = SupportedAuth.None;
            foreach (string extension in extensions)
            {
                if (string.Compare(extension, 0, AuthExtension, 0,
                    SizeOfAuthExtension, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    // remove the AUTH text including the following character 
                    // to ensure that split only gets the modules supported
                    string[] authTypes = extension.Remove(0, SizeOfAuthExtension).Split(s_authExtensionSplitters, StringSplitOptions.RemoveEmptyEntries);
                    foreach (string authType in authTypes)
                    {
                        if (string.Equals(authType, AuthLogin, StringComparison.OrdinalIgnoreCase))
                        {
                            _supportedAuth |= SupportedAuth.Login;
                        }
                        else if (string.Equals(authType, AuthNtlm, StringComparison.OrdinalIgnoreCase))
                        {
                            _supportedAuth |= SupportedAuth.NTLM;
                        }
                        else if (string.Equals(authType, AuthGssapi, StringComparison.OrdinalIgnoreCase))
                        {
                            _supportedAuth |= SupportedAuth.GSSAPI;
                        }
                    }
                }
                else if (string.Compare(extension, 0, "dsn ", 0, 3, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    _dsnEnabled = true;
                }
                else if (string.Compare(extension, 0, "STARTTLS", 0, 8, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    _serverSupportsStartTls = true;
                }
                else if (string.Compare(extension, 0, "SMTPUTF8", 0, 8, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    _serverSupportsEai = true;
                }
            }
        }

Usage Example

Example #1
0
            bool SendEHello()//4
            {
                IAsyncResult result = EHelloCommand.BeginSend(connection, connection.client.clientDomain, sendEHelloCallback, this);

                if (result.CompletedSynchronously)
                {
                    connection.extensions = EHelloCommand.EndSend(result);
                    connection.ParseExtensions(connection.extensions);
                    // If we already have a TlsStream, this is the second EHLO cmd
                    // that we sent after TLS handshake compelted. So skip TLS and
                    // continue with Authenticate.
                    if (connection.pooledStream.NetworkStream is TlsStream)
                    {
                        Authenticate();
                        return(true);
                    }

                    if (connection.EnableSsl)
                    {
#if !FEATURE_PAL
                        if (!connection.serverSupportsStartTls)
                        {
                            // Either TLS is already established or server does not support TLS
                            if (!(connection.pooledStream.NetworkStream is TlsStream))
                            {
                                throw new SmtpException(SR.GetString(SR.MailServerDoesNotSupportStartTls));
                            }
                        }

                        SendStartTls();
#else // FEATURE_PAL
                        throw new NotSupportedException("ROTORTODO");
#endif // !FEATURE_PAL
                    }
                    else
                    {
                        Authenticate();
                    }
                    return(true);
                }
                return(false);
            }
All Usage Examples Of System.Net.Mail.SmtpConnection::ParseExtensions