public Ml(Kernel kernel, Logger logger, MailSave mailSave, MlOption mlOption,string mlName,List<string>domainList) { Status = false; _kernel = kernel; _logger = logger; _mlName = mlName; //_mlOption = mlOption; _mlMailDb = new MlMailDb(logger, mlOption.ManageDir, mlName); if (!_mlMailDb.Status) { return;//初期化中断 } _mlAddr = new MlAddr(mlName, domainList); _mlUserList = new MlUserList(mlOption.MemberList); _mlSender = new MlSender(mailSave, logger); var mlSubject = new MlSubject(mlOption.TitleKind, mlName); _mlDevivery = new MlDelivery(mailSave, logger,_mlUserList, _mlAddr, _mlMailDb, mlSubject, mlOption.Docs,mlOption.MaxGet); _mlCreator2 = new MlCreator(_mlAddr,mlOption.Docs); _autoRegistration = mlOption.AutoRegistration; const double effectiveMsec = 120 * 1000; //有効時間120秒 _mlSubscribeDb = new MlSubscribeDb(mlOption.ManageDir, mlName, effectiveMsec);//confirm文字列データベース if (!_mlMailDb.Status) { return;//初期化中断 } Status = true;//ステータス }
public Ml(Kernel kernel, Logger logger, MailSave mailSave, MlOption mlOption, string mlName, List <string> domainList) { Status = false; _kernel = kernel; _logger = logger; _mlName = mlName; //_mlOption = mlOption; _mlMailDb = new MlMailDb(logger, mlOption.ManageDir, mlName); if (!_mlMailDb.Status) { return;//初期化中断 } _mlAddr = new MlAddr(mlName, domainList); _mlUserList = new MlUserList(mlOption.MemberList); _mlSender = new MlSender(mailSave, logger); var mlSubject = new MlSubject(mlOption.TitleKind, mlName); _mlDevivery = new MlDelivery(mailSave, logger, _mlUserList, _mlAddr, _mlMailDb, mlSubject, mlOption.Docs, mlOption.MaxGet); _mlCreator2 = new MlCreator(_mlAddr, mlOption.Docs); _autoRegistration = mlOption.AutoRegistration; const double effectiveMsec = 120 * 1000; //有効時間120秒 _mlSubscribeDb = new MlSubscribeDb(mlOption.ManageDir, mlName, effectiveMsec); //confirm文字列データベース if (!_mlMailDb.Status) { return; //初期化中断 } Status = true; //ステータス }
public Fetch(Kernel kernel, MailSave mailSave, String domainName, IEnumerable <OneDat> fetchList, int timeout, int sizeLimit) : base(kernel.CreateLogger("FetchThread", true, null)) { _kernel = kernel; //_server = server; _logger = kernel.CreateLogger("Fetch", true, this); _listFetchJob = new ListFetchJob(kernel, mailSave, domainName, _logger, fetchList, timeout, sizeLimit); }
DateTime _dt = new DateTime(0); //最終処理時間 #endregion Fields #region Constructors public OneFetchJob(Kernel kernel, MailSave mailSave,String domainName,OneFetch oneFetch, int timeout, int sizeLimit) { _kernel = kernel; _mailSave = mailSave; _domainName = domainName; _oneFetch = oneFetch; _timeout = timeout; _sizeLimit = sizeLimit; }
public OneFetchJob(Kernel kernel, MailSave mailSave, String domainName, OneFetch oneFetch, int timeout, int sizeLimit) { _kernel = kernel; _mailSave = mailSave; _domainName = domainName; _oneFetch = oneFetch; _timeout = timeout; _sizeLimit = sizeLimit; }
public MlDelivery(MailSave mailSave, Logger logger, MlUserList mlUserList, MlAddr mlAddr, MlMailDb mlDb, MlSubject mlSubject,List<string>docs,int maxGet) { _mlUserList = mlUserList; _mlAddr = mlAddr; _logger = logger; _mlDb = mlDb; _mlSubject = mlSubject; _docs = docs; _maxGet = maxGet; _mlSender = new MlSender(mailSave, logger); }
public MlDelivery(MailSave mailSave, Logger logger, MlUserList mlUserList, MlAddr mlAddr, MlMailDb mlDb, MlSubject mlSubject, List <string> docs, int maxGet) { _mlUserList = mlUserList; _mlAddr = mlAddr; _logger = logger; _mlDb = mlDb; _mlSubject = mlSubject; _docs = docs; _maxGet = maxGet; _mlSender = new MlSender(mailSave, logger); }
public MlList(Kernel kernel, Server server, MailSave mailSave, List <string> domainList) { var optionMl = kernel.ListOption.Get("Ml"); //メーリングストの一覧を取得する var dat = (Dat)optionMl.GetValue("mlList"); if (dat != null) { foreach (var o2 in dat) { if (!o2.Enable) { continue; } //メーリングリスト名の読込 var mlName = o2.StrList[0]; var op = kernel.ListOption.Get("Ml-" + mlName); var logger = kernel.CreateLogger(mlName, (bool)op.GetValue("useDetailsLog"), server); var mlOption = new MlOption(kernel, op); //無効なメンバ指定の確認と警告 foreach (var d in mlOption.MemberList) { var mailAddress = new MailAddress(d.StrList[1]); //メールアドレス if (mailAddress.User != "" && mailAddress.Domain != "") { continue; } if (logger != null) { logger.Set(LogKind.Error, null, 53, string.Format("{0}", d.StrList[1])); } } if (mlOption.MemberList.Count == 0) { logger.Set(LogKind.Error, null, 57, string.Format("{0}", mlName)); continue; } var ml = new Ml(kernel, logger, mailSave, mlOption, mlName, domainList); //MLの管理領域の初期化に失敗している場合は、追加しない if (!ml.Status) { continue; } _ar.Add(ml); if (logger != null) { logger.Set(LogKind.Normal, null, 44, mlName); } } } }
public Initialization2() { var tsDir = new TsDir(); //var tsOption = new TsOption(tsDir); //var manageDir = tsDir.Src + "\\TestDir"; //TmpDir2 = string.Format("{0}/../../TestDir", Directory.GetCurrentDirectory()); var optionDef = tsDir.Src + "\\Option.def"; //Docs Docs = new List<string>(); var lines = File.ReadAllLines(optionDef, Encoding.GetEncoding(932)); foreach (MlDocKind docKind in Enum.GetValues(typeof(MlDocKind))) { var tag = string.Format("MEMO=Ml\b{0}Document=", docKind.ToString().ToLower()); bool hit = false; foreach (var l in lines) { if (l.IndexOf(tag) == 0) { Docs.Add(l.Substring(tag.Length)); hit = true; break; } } if (!hit) { Docs.Add(""); } } Kernel = new Kernel(null, null, null, null); Logger = Kernel.CreateLogger("LOG", true, null); domainList = new List<string>() { "example.com" }; MlAddr = new MlAddr(mlName, domainList); var mailQueue = new MailQueue(tsDir.Src + "TestDir"); var oneOption = new Option(Kernel,"",""); var mailBox = new MailBox(Kernel, oneOption); MailSave = new MailSave(Kernel,mailBox,Logger,mailQueue,"",domainList); MlOption = CreateMlOption(); //MlUserList = CreateMlUsers(); Ml = new Ml(Kernel, Logger, MailSave, MlOption, mlName, domainList); //30件のメールを保存 for (int i = 0; i < 30; i++) { var mail = new Mail(null); mail.Init(Encoding.ASCII.GetBytes("\r\n"));//区切り行(ヘッダ終了) mail.AddHeader("subject", string.Format("[{0}:{1:D5}]TITLE", mlName, i + 1)); mail.Init(Encoding.ASCII.GetBytes("1\r\n"));//本文 mail.Init(Encoding.ASCII.GetBytes("2\r\n"));//本文 mail.Init(Encoding.ASCII.GetBytes("3\r\n"));//本文 Ml.Save(mail); } }
public ListFetchJob(Kernel kernel, MailSave mailSave, String domainName, Logger logger, IEnumerable <OneDat> fetchList, int timeout, int sizeLimit) { if (fetchList != null) { foreach (var o in fetchList) { if (o.Enable) { var interval = Convert.ToInt32(o.StrList[0]); //受信間隔 var host = o.StrList[1]; //サーバ var port = Convert.ToInt32(o.StrList[2]); //ポート var user = o.StrList[3]; //ユーザ var pass = Crypt.Decrypt(o.StrList[4]); //パスワード var localUser = o.StrList[5]; //ローカルユーザ //Ver5.2.7 旧バージョン(5.2以前)との互換のため int synchronize; try { synchronize = Convert.ToInt32(o.StrList[6]); //同期 } catch { var s = o.StrList[6]; if (s == "サーバに残す" || s == "An email of a server does not eliminate it") { synchronize = 0; } else if (s == "メールボックスと同期する" || s == "Synchronize it with a mailbox") { synchronize = 1; } else if (s == "サーバから削除する" || s == "An email of a server eliminates it") { synchronize = 2; } else { continue; //コンバート失敗したので設定データは無効 } } var keepTime = Convert.ToInt32(o.StrList[7]); //サーバに残す時間 var oneFetch = new OneFetch(interval, host, port, user, pass, localUser, synchronize, keepTime); if (oneFetch.Ip == null) { logger.Set(LogKind.Error, null, 0, string.Format("host={0}", host)); } Ar.Add(new OneFetchJob(kernel, mailSave, domainName, oneFetch, timeout, sizeLimit)); } } } }
public MlList(Kernel kernel,Server server,MailSave mailSave, List<string> domainList) { var optionMl = kernel.ListOption.Get("Ml"); //メーリングストの一覧を取得する var dat = (Dat) optionMl.GetValue("mlList"); if (dat != null){ foreach (var o2 in dat){ if (!o2.Enable) continue; //メーリングリスト名の読込 var mlName = o2.StrList[0]; var op = kernel.ListOption.Get("Ml-" + mlName); var logger = kernel.CreateLogger(mlName, (bool) op.GetValue("useDetailsLog"), server); var mlOption = new MlOption(kernel,op); //無効なメンバ指定の確認と警告 foreach (var d in mlOption.MemberList){ var mailAddress = new MailAddress(d.StrList[1]); //メールアドレス if (mailAddress.User != "" && mailAddress.Domain != "") continue; if (logger != null){ logger.Set(LogKind.Error, null, 53, string.Format("{0}", d.StrList[1])); } } if (mlOption.MemberList.Count == 0){ logger.Set(LogKind.Error, null, 57, string.Format("{0}", mlName)); continue; } var ml = new Ml(kernel, logger, mailSave, mlOption, mlName, domainList); //MLの管理領域の初期化に失敗している場合は、追加しない if (!ml.Status) continue; _ar.Add(ml); if (logger != null) logger.Set(LogKind.Normal, null, 44, mlName); } } }
public void SetUp() { var tsDir = new TsDir(); _tsOption = new TsOption(tsDir); _tsOption.Set("FOLDER", "MailBox", "dir", string.Format("{0}\\MailBox", tsDir.Src)); //user1,user2,user3 _tsOption.Set("DAT", "MailBox", "user", "user1\tpass\buser2\tpass\buser3\tpass"); var kernel = new Kernel(null, null, null, null); var logger = new Logger(kernel, "LOG", false, null); var manageDir = tsDir.Src + "\\TestDir"; //MailQueue _mailQueue = new MailQueue(tsDir.Src + "\\MailQueue"); var oneOption = kernel.ListOption.Get("MailBox"); _mailBox = new MailBox(kernel, oneOption); var mailSave = new MailSave(kernel, _mailBox, logger, _mailQueue, "", _domainList);//モック var memberList = new Dat(); memberList.Add(true, string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "USER1", "*****@*****.**", false, true, true, "")); //一般・読者・投稿 memberList.Add(true, string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "USER2", "*****@*****.**", false, true, false, ""));//一般・読者・× memberList.Add(true, string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "USER3", "*****@*****.**", false, false, true, ""));//一般・×・投稿 //memberList.Add(false, string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "USER6" , "*****@*****.**" , false, false, true, ""));//一般・×・投稿 (Disable) //memberList.Add(true, string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "ADMIN" , "*****@*****.**" , true, false, true, "123"));//管理者・×・投稿 //memberList.Add(true, string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "ADMIN2", "*****@*****.**", true, true, true, "456"));//管理者・読者・投稿 //memberList.Add(false, string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "ADMIN3", "*****@*****.**", true, true, true, "789"));//管理者・読者・投稿 (Disable) var docs = (from object o in Enum.GetValues(typeof(MLDocKind)) select "").ToList(); const int maxSummary = 10; const int getMax = 10; const bool autoRegistration = true; const int titleKind = 1; var mlOption = new MlOption(maxSummary, getMax, autoRegistration, titleKind, docs, manageDir, memberList); _ml = new Ml(kernel, logger, mailSave, mlOption, _mlName, _domainList); }
Fetch _fetch; //自動受信 #endregion Fields #region Constructors //#endif //コンストラクタ public Server(Kernel kernel, Conf conf, OneBind oneBind) : base(kernel, conf, oneBind) { //Ver5.8.9 if (kernel.RunMode == RunMode.Normal || kernel.RunMode == RunMode.Service) { //メールボックスの初期化状態確認 if (kernel.MailBox == null || !kernel.MailBox.Status) { Logger.Set(LogKind.Error, null, 4, ""); return; //初期化失敗(サーバは機能しない) } } //ドメイン名のリスト整備 DomainList = new List<string>(); foreach (var s in ((string)Conf.Get("domainName")).Split(',')) { //Ver6.1.9 // 設定時に誤って空白が入ってしまった際、強制的に削除する DomainList.Add(s.Trim()); //DomainList.Add(s); } if (DomainList.Count == 0) { Logger.Set(LogKind.Error, null, 3, ""); return;//初期化失敗(サーバは機能しない) } //エリアス初期化 Alias = new Alias(DomainList, kernel.MailBox); foreach (var dat in (Dat)Conf.Get("aliasList")) { if (dat.Enable) { var name = dat.StrList[0]; var alias = dat.StrList[1]; Alias.Add(name, alias, Logger); } } //メールキューの初期化 _mailQueue = new MailQueue(kernel.ProgDir()); //SaveMail初期化 var receivedHeader = new ReceivedHeader(kernel, (string)Conf.Get("receivedHeader")); _mailSave = new MailSave(kernel.MailBox,Alias, _mailQueue,Logger, receivedHeader, DomainList); var always = (bool)Conf.Get("always");//キュー常時処理 _agent = new Agent(kernel, this, Conf, Logger, _mailQueue, always); //中継許可の初期化 _relay = new Relay((Dat)Conf.Get("allowList"), (Dat)Conf.Get("denyList"), (int)Conf.Get("order"), Logger); //PopBeforeSmtp _popBeforeSmtp = new PopBeforeSmtp((bool)conf.Get("usePopBeforeSmtp"), (int)conf.Get("timePopBeforeSmtp"), kernel.MailBox); //usePopAccountがfalseの時、内部でmailBoxが無効化される _smtpAuthUserList = new SmtpAuthUserList((bool)Conf.Get("usePopAcount"), Kernel.MailBox, (Dat)Conf.Get("esmtpUserList")); _smtpAuthRange = new SmtpAuthRange((Dat)Conf.Get("range"), (int)Conf.Get("enableEsmtp"), Logger); //ヘッダ置換 _changeHeader = new ChangeHeader((Dat)Conf.Get("patternList"), (Dat)Conf.Get("appendList")); //Ver5.3.3 Ver5.2以前のバージョンのカラムの違いを修正する var d = (Dat)Conf.Get("hostList"); if (d.Count > 0 && d[0].StrList.Count == 6) { foreach (var o in d) { o.StrList.Add("False"); } conf.Set("hostList", d); conf.Save(kernel.IniDb); } //#if ML_SERVER _mlList = new MlList(kernel,this,_mailSave, DomainList); //#endif }
public MlSender(MailSave mailSave, Logger logger) { _mailSave = mailSave; _logger = logger; }
public MlSender2(MailSave mailSave,Logger logger) { this.mailSave = mailSave; this.logger = logger; }
readonly MlList _mlList;//MLリスト //#endif //コンストラクタ public Server(Kernel kernel, Conf conf, OneBind oneBind) : base(kernel, conf, oneBind) { //Ver5.8.9 if (kernel.RunMode == RunMode.Normal || kernel.RunMode == RunMode.Service) { //メールボックスの初期化状態確認 if (kernel.MailBox == null || !kernel.MailBox.Status) { Logger.Set(LogKind.Error, null, 4, ""); return; //初期化失敗(サーバは機能しない) } } //ドメイン名のリスト整備 DomainList = new List <string>(); foreach (var s in ((string)Conf.Get("domainName")).Split(',')) { //Ver6.1.9 // 設定時に誤って空白が入ってしまった際、強制的に削除する DomainList.Add(s.Trim()); //DomainList.Add(s); } if (DomainList.Count == 0) { Logger.Set(LogKind.Error, null, 3, ""); return;//初期化失敗(サーバは機能しない) } //エリアス初期化 Alias = new Alias(DomainList, kernel.MailBox); foreach (var dat in (Dat)Conf.Get("aliasList")) { if (dat.Enable) { var name = dat.StrList[0]; var alias = dat.StrList[1]; Alias.Add(name, alias, Logger); } } //メールキューの初期化 _mailQueue = new MailQueue(kernel.ProgDir()); //SaveMail初期化 var receivedHeader = new ReceivedHeader(kernel, (string)Conf.Get("receivedHeader")); _mailSave = new MailSave(kernel.MailBox, Alias, _mailQueue, Logger, receivedHeader, DomainList); var always = (bool)Conf.Get("always");//キュー常時処理 _agent = new Agent(kernel, this, Conf, Logger, _mailQueue, always); //中継許可の初期化 _relay = new Relay((Dat)Conf.Get("allowList"), (Dat)Conf.Get("denyList"), (int)Conf.Get("order"), Logger); //PopBeforeSmtp _popBeforeSmtp = new PopBeforeSmtp((bool)conf.Get("usePopBeforeSmtp"), (int)conf.Get("timePopBeforeSmtp"), kernel.MailBox); //usePopAccountがfalseの時、内部でmailBoxが無効化される _smtpAuthUserList = new SmtpAuthUserList((bool)Conf.Get("usePopAcount"), Kernel.MailBox, (Dat)Conf.Get("esmtpUserList")); _smtpAuthRange = new SmtpAuthRange((Dat)Conf.Get("range"), (int)Conf.Get("enableEsmtp"), Logger); //ヘッダ置換 _changeHeader = new ChangeHeader((Dat)Conf.Get("patternList"), (Dat)Conf.Get("appendList")); //Ver5.3.3 Ver5.2以前のバージョンのカラムの違いを修正する var d = (Dat)Conf.Get("hostList"); if (d.Count > 0 && d[0].StrList.Count == 6) { foreach (var o in d) { o.StrList.Add("False"); } conf.Set("hostList", d); conf.Save(kernel.IniDb); } //#if ML_SERVER _mlList = new MlList(kernel, this, _mailSave, DomainList); //#endif }
public MlSender2(MailSave mailSave, Logger logger) { this.mailSave = mailSave; this.logger = logger; }