Пример #1
0
        public void Appendによるヘッダの追加()
        {
            //setUp
            var appned = new Dat(new CtrlType[] { CtrlType.TextBox, CtrlType.TextBox });
            appned.Add(true, "tag2\tzzz");
            var sut = new ChangeHeader(null, appned);

            var mail = new Mail();

            var expected = "zzz";

            //exercise
            sut.Exec(mail, new Logger());
            var actual = mail.GetHeader("tag2");

            //varify
            Assert.That(actual, Is.EqualTo(expected));
        }
Пример #2
0
        public void Relpaceによるヘッダの置き換え2()
        {
            //setUp
            var replace = new Dat(new CtrlType[] { CtrlType.TextBox, CtrlType.TextBox });
            replace.Add(true, "ABC\tBBB");
            var sut = new ChangeHeader(replace, null);

            var mail = new Mail();
            mail.AddHeader("tag1", "ABC123");
            mail.AddHeader("tag2", "DEF123");
            mail.AddHeader("tag3", "GHI123");

            var expected = "BBB123";

            //exercise
            sut.Exec(mail, new Logger());
            var actual = mail.GetHeader("tag1");

            //varify
            Assert.That(actual, Is.EqualTo(expected));
        }
Пример #3
0
        public void Relpaceによるヘッダの置き換え()
        {
            //setUp
            var replace = new Dat(new CtrlType[]{CtrlType.TextBox, CtrlType.TextBox});
            replace.Add(true, "ABC\tXYZ");
            var sut = new ChangeHeader(replace, null);

            var mail = new Mail();
            mail.AddHeader("tag1", "ABC123");
            mail.AddHeader("tag2", "DEF123");
            mail.AddHeader("tag3", "GHI123");

            var expected = "tag1: XYZ123\r\n";

            //exercise
            sut.Exec(mail, new Logger());
            var actual = Encoding.ASCII.GetString(mail.GetBytes()).Substring(0, 14);

            //varify
            Assert.That(actual, Is.EqualTo(expected));
        }
Пример #4
0
        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
        }
Пример #5
0
        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
        }
Пример #6
0
        public void Relpaceによるヘッダの置き換え3()
        {
            //setUp
            var replace = new Dat(new CtrlType[] { CtrlType.TextBox, CtrlType.TextBox });
            replace.Add(true, "EFGH\tWXYZ");
            var sut = new ChangeHeader(replace, null);

            var mail = new Mail();
            mail.AddHeader("To", "\"ABCD\" <****@******>");
            mail.AddHeader("From", "\"EFGH\" <****@******>");
            mail.AddHeader("Subject", "test");

            var expected = "\"WXYZ\" <****@******>";

            //exercise
            sut.Exec(mail, new Logger());
            var actual = mail.GetHeader("From");

            //varify
            Assert.That(actual, Is.EqualTo(expected));
        }
Пример #7
0
        public void Relpaceによるヘッダの置き換え4()
        {
            //setUp
            var replace = new Dat(new CtrlType[] { CtrlType.TextBox, CtrlType.TextBox });
            replace.Add(true, "User-Agent:.*\tUser-Agent:Henteko Mailer 09.87.12");
            var sut = new ChangeHeader(replace, null);

            var mail = new Mail();
            mail.AddHeader("User-Agent", "Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20130801 Thunderbird/17.0.8");

            var expected = "Henteko Mailer 09.87.12";

            //exercise
            sut.Exec(mail, new Logger());
            var actual = mail.GetHeader("User-Agent");

            //varify
            Assert.That(actual, Is.EqualTo(expected));
        }