Esempio n. 1
0
        public void AolStartTlsTest()
        {
            var profi_trol = new MailBox
            {
                Name  = "",
                EMail = new MailAddress("*****@*****.**"),

                Account                = "profi.troll",
                Password               = "******",
                AuthenticationTypeIn   = SaslMechanism.Login,
                IncomingEncryptionType = EncryptionType.StartTLS,
                Imap   = true,
                Port   = 143,
                Server = "imap.aol.com",

                SmtpAccount             = "profi.troll",
                SmtpPassword            = "******",
                AuthenticationTypeSmtp  = SaslMechanism.Login,
                OutcomingEncryptionType = EncryptionType.StartTLS,
                SmtpPort   = 587,
                SmtpServer = "smtp.aol.com"
            };

            Assert.IsTrue(profi_trol.Test());
        }
        public void AolStartTlsTest()
        {
            var profi_trol = new MailBox
                {
                    Name = "",
                    EMail = new MailAddress("*****@*****.**"),
                    
                    Account = "profi.troll",
                    Password = "******",
                    AuthenticationTypeIn = SaslMechanism.Login,
                    IncomingEncryptionType = EncryptionType.StartTLS,
                    Imap = true,
                    Port = 143,
                    Server = "imap.aol.com",

                    SmtpAccount = "profi.troll",
                    SmtpPassword = "******",
                    AuthenticationTypeSmtp = SaslMechanism.Login,
                    OutcomingEncryptionType = EncryptionType.StartTLS,
                    SmtpPort = 587,
                    SmtpServer = "smtp.aol.com"
                };
            Assert.IsTrue(profi_trol.Test());
        }
Esempio n. 3
0
        public MailBox CreateAccount(string name,
                                     string email,
                                     string account,
                                     string password,
                                     int port,
                                     string server,
                                     string smtp_account,
                                     string smtp_password,
                                     int smtp_port,
                                     string smtp_server,
                                     bool smtp_auth,
                                     bool imap,
                                     bool restrict,
                                     EncryptionType incoming_encryption_type,
                                     EncryptionType outcoming_encryption_type,
                                     SaslMechanism auth_type_in,
                                     SaslMechanism auth_type_smtp)
        {
            string error_text;
            var    mbox = new MailBox
            {
                Name         = name,
                EMail        = new MailAddress(email),
                Account      = account,
                Password     = password,
                Port         = port,
                Server       = server,
                SmtpAccount  = smtp_account,
                SmtpPassword = smtp_password,
                SmtpPort     = smtp_port,
                SmtpServer   = smtp_server,
                SmtpAuth     = smtp_auth,
                Imap         = imap,
                Restrict     = restrict,
                TenantId     = TenantId,
                UserId       = Username,
                BeginDate    = restrict ?
                               DateTime.Now.Subtract(new TimeSpan(MailBox.DefaultMailLimitedTimeDelta)) :
                               new DateTime(MailBox.DefaultMailBeginTimestamp),
                IncomingEncryptionType  = incoming_encryption_type,
                OutcomingEncryptionType = outcoming_encryption_type,
                AuthenticationTypeIn    = auth_type_in,
                AuthenticationTypeSmtp  = auth_type_smtp
            };

            try
            {
                mbox.Test();

                mbox.InServerId = mailBoxManager.SaveMailServerSettings(mbox.EMail,
                                                                        new MailServerSettings
                {
                    AccountName        = mbox.Account,
                    AccountPass        = mbox.Password,
                    AuthenticationType = mbox.AuthenticationTypeIn,
                    EncryptionType     = mbox.IncomingEncryptionType,
                    Port = mbox.Port,
                    Url  = mbox.Server
                },
                                                                        imap ? "imap" : "pop3", AuthorizationServiceType.Unknown);
                mbox.SmtpServerId = mailBoxManager.SaveMailServerSettings(mbox.EMail,
                                                                          new MailServerSettings
                {
                    AccountName        = mbox.SmtpAccount,
                    AccountPass        = mbox.SmtpPassword,
                    AuthenticationType = mbox.AuthenticationTypeSmtp,
                    EncryptionType     = mbox.OutcomingEncryptionType,
                    Port = mbox.SmtpPort,
                    Url  = mbox.SmtpServer
                },
                                                                          "smtp", AuthorizationServiceType.Unknown);

                mailBoxManager.SaveMailBox(mbox);
                return(mbox);
            }
            catch (ImapConnectionException ex_imap)
            {
                error_text = GetFormattedTextError(ex_imap, ServerType.Imap);
            }
            catch (Pop3ConnectionException ex_pop3)
            {
                error_text = GetFormattedTextError(ex_pop3, ServerType.Pop3);
            }
            catch (SmtpConnectionException ex_smtp)
            {
                error_text = GetFormattedTextError(ex_smtp, ServerType.Smtp);
            }
            catch (Exception ex)
            {
                error_text = GetFormattedTextError(ex, imap ? ServerType.Imap : ServerType.Pop3);
            }

            throw new Exception(error_text);
        }
        public MailBox CreateAccount(string name,
            string email,
            string account,
            string password,
            int port,
            string server,
            string smtp_account,
            string smtp_password,
            int smtp_port,
            string smtp_server,
            bool smtp_auth,
            bool imap,
            bool restrict,
            EncryptionType incoming_encryption_type,
            EncryptionType outcoming_encryption_type,
            SaslMechanism auth_type_in,
            SaslMechanism auth_type_smtp)
        {

            string error_text;
            var mbox = new MailBox
                {
                    Name = name,
                    EMail = new MailAddress(email),
                    Account = account,
                    Password = password,
                    Port = port,
                    Server = server,
                    SmtpAccount = smtp_account,
                    SmtpPassword = smtp_password,
                    SmtpPort = smtp_port,
                    SmtpServer = smtp_server,
                    SmtpAuth = smtp_auth,
                    Imap = imap,
                    Restrict = restrict,
                    TenantId = TenantId,
                    UserId = Username,
                    BeginDate = restrict ? 
                        DateTime.Now.Subtract(new TimeSpan(MailBox.DefaultMailLimitedTimeDelta)) : 
                        new DateTime(MailBox.DefaultMailBeginTimestamp),
                    IncomingEncryptionType = incoming_encryption_type,
                    OutcomingEncryptionType = outcoming_encryption_type,
                    AuthenticationTypeIn = auth_type_in,
                    AuthenticationTypeSmtp = auth_type_smtp
                };

            try
            {
                mbox.Test();

                mbox.InServerId = mailBoxManager.SaveMailServerSettings(mbox.EMail,
                                        new MailServerSettings
                                        {
                                            AccountName = mbox.Account,
                                            AccountPass = mbox.Password,
                                            AuthenticationType = mbox.AuthenticationTypeIn,
                                            EncryptionType = mbox.IncomingEncryptionType,
                                            Port = mbox.Port,
                                            Url = mbox.Server
                                        },
                                        imap ? "imap" : "pop3", AuthorizationServiceType.Unknown);
                mbox.SmtpServerId = mailBoxManager.SaveMailServerSettings(mbox.EMail,
                                        new MailServerSettings
                                        {
                                        AccountName = mbox.SmtpAccount,
                                        AccountPass = mbox.SmtpPassword,
                                        AuthenticationType = mbox.AuthenticationTypeSmtp,
                                        EncryptionType = mbox.OutcomingEncryptionType,
                                        Port = mbox.SmtpPort,
                                        Url = mbox.SmtpServer
                                        },
                                        "smtp", AuthorizationServiceType.Unknown);

                mailBoxManager.SaveMailBox(mbox);
                return mbox;
            }
            catch (ImapConnectionException ex_imap)
            {
                error_text = GetFormattedTextError(ex_imap, ServerType.Imap);
            }
            catch (Pop3ConnectionException ex_pop3)
            {
                error_text = GetFormattedTextError(ex_pop3, ServerType.Pop3);
            }
            catch (SmtpConnectionException ex_smtp)
            {
                error_text = GetFormattedTextError(ex_smtp, ServerType.Smtp);
            }
            catch (Exception ex)
            {
                error_text = GetFormattedTextError(ex, imap ? ServerType.Imap : ServerType.Pop3);
            }

            throw new Exception(error_text);

        }