Example #1
0
 /*
  * Page Events
  */
 protected void Page_Init()
 {
     if (!this.IsPostBack)
     {
         if (selectculture != null)
         {
             selectculture.DataSource     = Application["AvailableCultures"];
             selectculture.DataTextField  = "Key";
             selectculture.DataValueField = "Value";
             selectculture.DataBind();
             if (selectculture.Items.Count == 0)
             {
                 selectculture.Visible = false;
             }
             else
             {
                 selectculture.Value = Session["effectiveculture"].ToString();
             }
         }
         if (selectserver != null && Application["sharpwebmail/login/serverselection"] != null && Application["sharpwebmail/login/serverselection"].Equals("manual"))
         {
             anmar.SharpWebMail.ServerSelector selector = (anmar.SharpWebMail.ServerSelector)Application["sharpwebmail/read/servers"];
             selectserver.DataSource    = selector.Servers;
             selectserver.DataTextField = "Name";
             selectserver.DataBind();
             if (selectserver.Items.Count != 0)
             {
                 selectserver.Visible = true;
             }
         }
     }
 }
        private anmar.SharpWebMail.ServerSelector ParseConfigServers(System.Xml.XmlNodeList list)
        {
            anmar.SharpWebMail.ServerSelector selector = new anmar.SharpWebMail.ServerSelector();
            foreach (System.Xml.XmlNode item in list)
            {
                if (item.NodeType.Equals(System.Xml.XmlNodeType.Element) && (item.LocalName.Equals("server") || item.LocalName.Equals("add")))
                {
                    System.Xml.XmlElement element = (System.Xml.XmlElement)item;
                    if (element.HasAttribute("key") && element.HasAttribute("value"))                       // Old format
                    {
                        selector.Add(element.GetAttribute("key"), element.GetAttribute("value"));
                    }
                    else if (element.HasAttribute("protocol") && element.HasAttribute("host") && element.HasAttribute("port"))                         // New format
                    {
                        anmar.SharpWebMail.EmailServerInfo server = new anmar.SharpWebMail.EmailServerInfo(element.GetAttribute("protocol"), element.GetAttribute("host"), element.GetAttribute("port"));
                        if (element.HasAttribute("regexp"))
                        {
                            server.SetCondition(element.GetAttribute("regexp"));
                        }
                        if (element.HasAttribute("name"))
                        {
                            server.Name = element.GetAttribute("name");
                        }

                        if (server.IsValid())
                        {
                            selector.Add(server);
                        }
                    }
                }
            }
            return(selector);
        }
Example #3
0
        /// <summary>
        ///
        /// </summary>
        protected void Send_Click(System.Object sender, System.EventArgs args)
        {
            System.String message = null;
            if (this.IsValid)
            {
                this.UI_case = 1;
                if ((int)Application["sharpwebmail/send/message/sanitizer_mode"] == 1)
                {
                    FCKEditor.Value = anmar.SharpWebMail.BasicSanitizer.SanitizeHTML(FCKEditor.Value, anmar.SharpWebMail.SanitizerMode.CommentBlocks | anmar.SharpWebMail.SanitizerMode.RemoveEvents);
                }
                anmar.SharpWebMail.ServerSelector  selector = (anmar.SharpWebMail.ServerSelector)Application["sharpwebmail/send/servers"];
                anmar.SharpWebMail.EmailServerInfo server   = selector.Select(User.Identity.Name, true);
                if (server != null && (server.Protocol.Equals(anmar.SharpWebMail.ServerProtocol.Smtp) ||
                                       server.Protocol.Equals(anmar.SharpWebMail.ServerProtocol.SmtpAuth)))
                {
                    if (Application["sharpwebmail/send/message/smtp_engine"].Equals("opensmtp"))
                    {
                        message = this.SendMailOpenSmtp(server);
                    }
                    else if (Application["sharpwebmail/send/message/smtp_engine"].Equals("dotnetopenmail"))
                    {
                        message = this.SendMailDotNetOpenMail(server);
                    }
                    else
                    {
                        message = this.SendMail(server);
                    }

                    if (message == null)
                    {
                        message = this.SharpUI.LocalizedRS.GetString("newMessageSent");
                    }
                }
            }
            else
            {
                message = this.SharpUI.LocalizedRS.GetString("newMessageValidationError");
            }
            newMessageWindowConfirmation.Text = message;
        }
Example #4
0
 protected void Login_Click(System.Object sender, System.EventArgs args)
 {
     // authenticate user
     if (this.IsValid)
     {
         int login_mode = (int)Application["sharpwebmail/login/mode"];
         if (login_mode == 3 && Application["sharpwebmail/login/append"] != null)
         {
             if (this.username.Value.IndexOf("@") == -1)
             {
                 this.username.Value = System.String.Format("{0}@{1}", this.username.Value, Application["sharpwebmail/login/append"]);
             }
             this.usernameValidator.ValidationExpression = "^" + anmar.SharpMimeTools.ABNF.addr_spec + "$";
             this.usernameValidator.Validate();
         }
         if (this.IsValid)
         {
             this.username.Value = this.PrepareLogin(this.username.Value);
             anmar.SharpWebMail.ServerSelector  selector = (anmar.SharpWebMail.ServerSelector)Application["sharpwebmail/read/servers"];
             anmar.SharpWebMail.EmailServerInfo server   = null;
             if (selectserver != null && selectserver.Visible)
             {
                 server = selector.Select(this.selectserver.Value, false);
             }
             else
             {
                 server = selector.Select(this.username.Value, true);
             }
             anmar.SharpWebMail.IEmailClient client = anmar.SharpWebMail.EmailClientFactory.CreateEmailClient(server, this.username.Value, password.Value);
             anmar.SharpWebMail.CTNInbox     inbox  = (anmar.SharpWebMail.CTNInbox)Session["inbox"];
             inbox.Client = client;
             System.String folder = Page.Request.QueryString["mode"];
             if (folder == null || folder.Length == 0)
             {
                 folder = "inbox";
             }
             inbox.CurrentFolder = folder;
             if (client != null && client.GetFolderIndex(inbox, 0, (int)Application["sharpwebmail/read/inbox/pagesize"], true))
             {
                 Session["client"] = client;
                 Session["inbox"]  = inbox;
                 if (login_mode == 2)
                 {
                     Session["DisplayEmail"] = client.UserName;
                 }
                 if (Application["sharpwebmail/send/addressbook"] != null)
                 {
                     System.Collections.SortedList addressbooks = (System.Collections.SortedList)Application["sharpwebmail/send/addressbook"];
                     foreach (System.Collections.Specialized.ListDictionary addressbook in addressbooks.Values)
                     {
                         if (addressbook.Contains("searchstringrealname"))
                         {
                             System.Data.DataTable result = anmar.SharpWebMail.UI.AddressBook.GetDataSource(addressbook, true, client);
                             if (result == null)
                             {
                                 continue;
                             }
                             if (result.Rows.Count == 1)
                             {
                                 Session["DisplayName"] = result.Rows[0][addressbook["namecolumn"].ToString()];
                                 if (login_mode == 2)
                                 {
                                     Session["DisplayEmail"] = result.Rows[0][addressbook["emailcolumn"].ToString()];
                                 }
                                 break;
                             }
                         }
                     }
                 }
                 if (log.IsDebugEnabled)
                 {
                     log.Debug(System.String.Concat("Successful authentication for user [", this.username.Value, "], found [", inbox.Count, "] messages. Setting cookie and redirecting."));
                 }
                 System.Web.Security.FormsAuthentication.RedirectFromLoginPage(this.username.Value, false);
             }
             else
             {
                 errorMsgLogin.Visible = true;
             }
             client   = null;
             inbox    = null;
             selector = null;
         }
     }
 }