public SmtpConnection(SmtpConnectionOptions options)
     : base(options.Host, options.Port, false, options.AllowInvalidRemoteCertificates)
 {
     _options       = options ?? throw new ArgumentNullException(nameof(options));
     ConnectionType = _options.ConnectionType;
     ComputeDefaultValues();
 }
 public SmtpConnection(SmtpConnectionOptions options)
     : base(options.Host, options.Port, false, options.AllowInvalidRemoteCertificates)
 {
     _options       = options;
     ConnectionType = _options.ConnectionType;
     ComputeDefaultValues();
 }
        private void ComputeDefaultValues()
        {
            switch (_options.ConnectionType)
            {
            case SmtpConnectionType.AUTO when Port == 465:
                ConnectionType = SmtpConnectionType.SSL;
                break;

            case SmtpConnectionType.AUTO when Port == 587:
                ConnectionType = SmtpConnectionType.TLS;
                break;
            }

            if (ConnectionType == SmtpConnectionType.AUTO)
            {
                throw new Exception($"Port {Port} is not a valid smtp port when using automatic configuration");
            }
        }