private static SmtpConfigValues MapOutgoingServer(OutgoingServer input, string emailAddress)
        {
            SmtpConfigValues returnVal = new SmtpConfigValues();

            returnVal.Username = input.GetUsernameFormatted(emailAddress);

            returnVal.Authentication = input.Authentication != AuthenticationType.None;
            returnVal.BCCMyself      = false;
            returnVal.EmailAddress   = emailAddress;
            returnVal.SmtpServer     = input.Hostname;
            returnVal.Port           = input.Port;

            switch (input.SocketType)
            {
            case SocketType.Plain:
                returnVal.SmtpSSLType = SSLType.None;
                break;

            case SocketType.SSL:
                returnVal.SmtpSSLType = SSLType.SSL;
                break;

            case SocketType.STARTTLS:
                returnVal.SmtpSSLType = SSLType.TLS;
                break;
            }

            return(returnVal);
        }
Example #2
0
        private void Scrape()
        {
            _config          = new SmtpConfigValues();
            _config.Verified = false;

            _config.SmtpServer = fbSmtpServer.TextValue;

            int port = 25;

            if (int.TryParse(fbPort.TextValue, out port))
            {
                _config.Port = port;
            }

            _config.EmailAddress          = fbEmailAddress.TextValue;
            _config.Authentication        = fbAuthentication.Checked;
            _config.UsePollingCredentials = fbUsePolling.Checked;
            _config.BCCMyself             = fbBccMyself.Checked;

            _config.SmtpSSLType = ConfigHelper.ParseEnumString <SSLType>(fbSSLType.SelectedValue);

            if (_config.Authentication && !_config.UsePollingCredentials)
            {
                _config.Username     = fbUserName.TextValue;
                _config.PasswordTrue = fbPassword.TextValue;
            }
            else
            {
                _config.Username     = string.Empty;
                _config.PasswordTrue = string.Empty;
            }
        }
        private static SmtpConfigValues ChooseOutgoingServer(EmailProvider provider, string emailAddress)
        {
            SmtpConfigValues returnVal = null;

            int            maxPort      = provider.OutgoingServers.Max(srv => srv.Port);
            OutgoingServer chosenServer = provider.OutgoingServers.Find(srv => srv.Port == maxPort);

            if (chosenServer != null)
            {
                returnVal = MapOutgoingServer(chosenServer, emailAddress);
            }

            return(returnVal);
        }