public MailClient(string type, string server, int port, AuthenticationType authenticationType, string userName, string userPassword, string userDomain) { _type = (MailClientType)Enum.Parse(typeof(MailClientType), type, true); _server = server; _port = port; _authenticationType = authenticationType; _userName = userName; _userPassword = userPassword; _userDomain = userDomain; }
private static BaseProtocolClient BuildMailClient(MailClientType type) { BaseProtocolClient client; switch (type) { case MailClientType.Imap: client = new Imap4Client(); break; case MailClientType.Pop3: client = new Pop3Client(); break; case MailClientType.Smtp: client = new SmtpClient(); break; default: throw new ArgumentException(String.Format("Unknown client type: {0}", type)); } try { client.TcpSendTimeout = Convert.ToInt32(WebConfigurationManager.AppSettings["mail.send-tcp-timeout"] ?? "30000"); client.TcpReceiveTimeout = Convert.ToInt32(WebConfigurationManager.AppSettings["mail.recieve-tcp-timeout"] ?? "30000"); client.CertificatePermit = Convert.ToBoolean(WebConfigurationManager.AppSettings["mail.certificate-permit"] ?? "false"); } catch (Exception e) { client.TcpReceiveTimeout = 30000; client.TcpSendTimeout = 30000; client.CertificatePermit = false; var logger = LogManager.GetLogger("MailBoxManager"); var message = String.Format("Problems with config parsing for SendTimeout: {0} or RecieveTimeout: {1}. Values was reseted to default - 30000.\n", WebConfigurationManager.AppSettings["mail.send-tcp-timeout"], WebConfigurationManager.AppSettings["mail.recieve-tcp-timeout"]); logger.DebugException(message, e); } return(client); }
private static BaseProtocolClient BuildMailClient(MailClientType type) { BaseProtocolClient client; switch (type) { case MailClientType.Imap: client = new Imap4Client(); break; case MailClientType.Pop3: client = new Pop3Client(); break; case MailClientType.Smtp: client = new SmtpClient(); break; default: throw new ArgumentException(String.Format("Unknown client type: {0}", type)); } try { client.SendTimeout = Convert.ToInt32(WebConfigurationManager.AppSettings["mail.send-tcp-timeout"] ?? "30000"); client.ReceiveTimeout = Convert.ToInt32(WebConfigurationManager.AppSettings["mail.recieve-tcp-timeout"] ?? "30000"); client.CertificatePermit = Convert.ToBoolean(WebConfigurationManager.AppSettings["mail.certificate-permit"] ?? "false"); } catch (Exception e) { client.ReceiveTimeout = 30000; client.SendTimeout = 30000; client.CertificatePermit = false; var logger = LogManager.GetLogger("MailBoxManager"); var message = String.Format("Problems with config parsing for SendTimeout: {0} or RecieveTimeout: {1}. Values was reseted to default - 30000.\n", WebConfigurationManager.AppSettings["mail.send-tcp-timeout"], WebConfigurationManager.AppSettings["mail.recieve-tcp-timeout"]); logger.DebugException(message, e); } return client; }