Ejemplo n.º 1
0
        public void TestEndToEnd(string messageText)
        {
            CDO.Message message = this.LoadMessage(messageText);

            string originalSubject     = message.Subject;
            string originalContentType = message.GetContentType();

            //
            // Outgoing
            //
            Assert.DoesNotThrow(() => m_handler.ProcessCDOMessage(message));

            message = this.LoadMessage(message); // re-load the message
            base.VerifyOutgoingMessage(message);
            //
            // Incoming
            //
            Assert.DoesNotThrow(() => m_handler.ProcessCDOMessage(message));

            message = this.LoadMessage(message); // re-load the message
            base.VerifyIncomingMessage(message);

            Assert.True(message.Subject.Equals(originalSubject));
            Assert.True(MimeStandard.Equals(message.GetContentType(), originalContentType));

            Message mailMessage = MailParser.ParseMessage(message.GetMessageText());
            string  header      = mailMessage.Headers.GetValue(SmtpAgent.XHeaders.Receivers);

            Assert.DoesNotThrow(() => MailParser.ParseAddressCollection(header));
            MailAddressCollection addresses = MailParser.ParseAddressCollection(header);

            Assert.True(addresses.Count > 0);
        }
Ejemplo n.º 2
0
        public Boolean AuthenticateByAPop()
        {
            String s          = "";
            String TimeStamp  = "";
            Int32  StartIndex = 0;
            Int32  EndIndex   = 0;

            if (this.EnsureOpen() == Pop3ConnectionState.Connected)
            {
                s = this.Execute("user " + this._UserName, false);
                if (s.StartsWith("+OK") == true)
                {
                    if (s.IndexOf("<") > -1 &&
                        s.IndexOf(">") > -1)
                    {
                        StartIndex = s.IndexOf("<");
                        EndIndex   = s.IndexOf(">");
                        TimeStamp  = s.Substring(StartIndex, EndIndex - StartIndex + 1);

                        s = this.Execute("pass " + MailParser.ToMd5DigestString(TimeStamp + this._Password), false);
                        if (s.StartsWith("+OK") == true)
                        {
                            this._State = Pop3ConnectionState.Authenticated;
                        }
                    }
                }
            }
            return(this._State == Pop3ConnectionState.Authenticated);
        }
Ejemplo n.º 3
0
        /// SMTPメールサーバーへLogin認証でログインします。
        /// <summary>
        /// SMTPメールサーバーへLogin認証でログインします。
        /// </summary>
        /// <returns></returns>
        public Boolean AuthenticateByLogin()
        {
            SmtpCommandResult rs = null;

            if (this.EnsureOpen() == SmtpConnectionState.Connected)
            {
                rs = this.Execute("Auth Login");
                if (rs.StatusCode != SmtpCommandResultCode.WaitingForAuthentication)
                {
                    return(false);
                }
                //ユーザー名送信
                rs = this.Execute(MailParser.ToBase64String(this.UserName));
                if (rs.StatusCode != SmtpCommandResultCode.WaitingForAuthentication)
                {
                    return(false);
                }
                //パスワード送信
                rs = this.Execute(MailParser.ToBase64String(this.Password));
                if (rs.StatusCode == SmtpCommandResultCode.AuthenticationSuccessful)
                {
                    this._State = SmtpConnectionState.Authenticated;
                }
            }
            return(this._State == SmtpConnectionState.Authenticated);
        }
Ejemplo n.º 4
0
        /// このインスタンスの値を元に、SmtpContentクラスのインスタンスを生成します。
        /// <summary>
        /// Create SmtpContent instance with this instance value.
        /// このインスタンスの値を元に、SmtpContentクラスのインスタンスを生成します。
        /// </summary>
        /// <returns></returns>
        public Smtp.SmtpContent CreateSmtpContent()
        {
            Smtp.SmtpContent ct = new HigLabo.Net.Smtp.SmtpContent();
            Field            f  = null;

            for (int i = 0; i < this.Header.Count; i++)
            {
                f = this.Header[i];
                if (String.IsNullOrEmpty(f.Value) == true)
                {
                    continue;
                }
                ct[f.Key] = MailParser.DecodeFromMailHeaderLine(f.Value);
            }
            for (int i = 0; i < this.ContentType.Fields.Count; i++)
            {
                f = this.ContentType.Fields[i];
                ct.ContentType.Fields.Add(new Field(f.Key, MailParser.DecodeFromMailHeaderLine(f.Value)));
            }
            for (int i = 0; i < this.ContentDisposition.Fields.Count; i++)
            {
                f = this.ContentDisposition.Fields[i];
                ct.ContentDisposition.Fields.Add(new Field(f.Key, MailParser.DecodeFromMailHeaderLine(f.Value)));
            }
            ct.LoadText(this.BodyText);
            for (int i = 0; i < this.Contents.Count; i++)
            {
                ct.Contents.Add(this.Contents[i].CreateSmtpContent());
            }
            return(ct);
        }
Ejemplo n.º 5
0
        public void TestFiles(string fileName)
        {
            string filePath = Path.Combine("Mail\\TestFiles", fileName);
            string mailtext = File.ReadAllText(filePath);

            Message message = null;

            Assert.DoesNotThrow(() => message = Message.Load(mailtext));

            if (SMIMEStandard.IsContentMultipartSignature(message.ParsedContentType))
            {
                SignedEntity signedEntity = null;

                Assert.DoesNotThrow(() => signedEntity = SignedEntity.Load(message));
                message.Headers = message.Headers.SelectNonMimeHeaders();
                message.UpdateBody(signedEntity.Content); // this will merge in content + content specific mime headers
            }

            Message extracted = null;

            Assert.DoesNotThrow(() => extracted = WrappedMessage.ExtractInner(message));

            Header to = null;

            Assert.DoesNotThrow(() => to = extracted.To);

            MailAddressCollection addresses = null;

            Assert.DoesNotThrow(() => addresses = MailParser.ParseAddressCollection(to));
            Assert.True(addresses.Count > 0);

            Assert.DoesNotThrow(() => MailParser.ParseMailAddress(extracted.From));
        }
Ejemplo n.º 6
0
        public void TestNoMDNSent()
        {
            Message msg = MailParser.ParseMessage(string.Format(TestMessage, Guid.NewGuid()));

            msg.RequestNotification();

            OutgoingMessage outgoing = null;
            IncomingMessage incoming = null;

            base.ProcessEndToEnd(m_agent, msg, out outgoing, out incoming);
            //
            // We have a valid MDN request, but the gateway is configured not to send them
            //
            m_agent.Settings.Notifications.AutoResponse = false;
            Assert.True(CountNotificationsToBeSent(incoming) == 0);
            //
            // Renable Acks on the gateway
            // Then generate an MDN Ack & pass it through the gateway
            // After end to end processing, we should receive a valid MDN
            // The receiving gateway should NOT generate an Ack
            //
            m_agent.Settings.Notifications.AutoResponse = true; // Gateway now enabled to send acks
            NotificationMessage notificationMessage = m_producer.Produce(incoming).First();

            this.ProcessEndToEnd(m_agent, notificationMessage, out outgoing, out incoming);

            Assert.True(incoming.Message.IsMDN());  // Verify that the receiver got a valid MDN
            //
            // The message is itself an MDN Response! Should not be able to send a response
            //
            Assert.True(CountNotificationsToBeSent(incoming) == 0);
        }
Ejemplo n.º 7
0
 protected virtual void EnsureBodyText()
 {
     if (this.BodyTextCreated == false)
     {
         if (this.ContentType.Value.IndexOf("message/rfc822") > -1)
         {
             this.BodyText = this.BodyData;
         }
         else if (this.IsMultiPart == true)
         {
             if (this.BodyContent == null)
             {
                 this.BodyText = "";
             }
             else
             {
                 this.BodyText = this.BodyContent.BodyText;
             }
         }
         else if (this.IsText == true)
         {
             this.BodyText = MailParser.DecodeFromMailBody(this.BodyData, this.ContentTransferEncoding, this.ContentEncoding);
         }
         else
         {
             this.BodyText = this.BodyData;
         }
     }
     this.BodyTextCreated = true;
 }
Ejemplo n.º 8
0
        /// 指定したMailIndexのメールをメールサーバーから削除します。
        /// <summary>
        /// Set delete flag to specify mail index.
        /// To complete delete execution,call quit command after calling dele command.
        /// 指定したMailIndexのメールに削除フラグをたてます。
        /// 実際に削除するにはさらにQUITコマンドで削除処理を完了させる必要があります。
        /// </summary>
        /// <param name="mailIndex"></param>
        /// <returns></returns>
        public Boolean DeleteEMail(params Int64[] mailIndex)
        {
            DeleCommand cm = null;
            String      s  = "";

            if (this.EnsureOpen() == Pop3ConnectionState.Disconnected)
            {
                return(false);
            }
            if (this.Authenticate() == false)
            {
                return(false);
            }
            for (int i = 0; i < mailIndex.Length; i++)
            {
                cm = new DeleCommand(mailIndex[i]);
                s  = this.Execute(cm);
                if (MailParser.IsResponseOk(s) == false)
                {
                    return(false);
                }
            }
            this.ExecuteQuit();
            return(true);
        }
Ejemplo n.º 9
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="key"></param>
 /// <returns></returns>
 public String this[String key]
 {
     get
     {
         Field f = InternetTextMessage.Field.FindField(this._Header, key);
         if (f == null)
         {
             return("");
         }
         else
         {
             if (this._DecodeHeaderText == true)
             {
                 return(MailParser.DecodeFromMailHeaderLine(f.Value));
             }
             else
             {
                 return(f.Value);
             }
         }
     }
     set
     {
         Field f = InternetTextMessage.Field.FindField(this._Header, key);
         if (f == null)
         {
             f = new Field(key, value);
             this._Header.Add(f);
         }
         else
         {
             f.Value = value;
         }
     }
 }
        public void should_recognize_Savoy_as_place()
        {
            const string text   = "Organize a coffee meeting in Savoy for us next month.";
            var          date   = new DateTime(2015, 1, 1);
            var          result = new MailParser().Parse(text, date);

            result.Place.Should().Be("Savoy");
        }
        public void should_recognize_Glazgo_as_place()
        {
            const string text   = "Organize a remote meeting in Glazgo for us next month.";
            var          date   = new DateTime(2015, 1, 1);
            var          result = new MailParser().Parse(text, date);

            result.Place.Should().Be("Glazgo");
        }
Ejemplo n.º 12
0
        public void DecodeData(Stream stream, Boolean isClose)
        {
            Byte[] bb = null;

            if (this.ContentTransferEncoding == TransferEncoding.Base64)
            {
                bb = Convert.FromBase64String(this.BodyData.Replace("\n", ""));
                BinaryWriter sw = null;
                try
                {
                    sw = new BinaryWriter(stream);
                    sw.Write(bb);
                    sw.Flush();
                }
                finally
                {
                    if (isClose == true)
                    {
                        sw.Close();
                    }
                }
            }
            else if (this.ContentTransferEncoding == TransferEncoding.QuotedPrintable)
            {
                StreamWriter sw = null;
                try
                {
                    sw = new StreamWriter(stream);
                    sw.Write(this.ContentEncoding.GetString(MailParser.FromQuotedPrintableText(this.BodyData)));
                    sw.Flush();
                }
                finally
                {
                    if (isClose == true)
                    {
                        sw.Close();
                    }
                }
            }
            else if (this.ContentTransferEncoding == TransferEncoding.SevenBit)
            {
                bb = Encoding.ASCII.GetBytes(this.BodyData);
                BinaryWriter sw = null;
                try
                {
                    sw = new BinaryWriter(stream);
                    sw.Write(bb);
                    sw.Flush();
                }
                finally
                {
                    if (isClose == true)
                    {
                        sw.Close();
                    }
                }
            }
        }
Ejemplo n.º 13
0
        /// 行の文字列を解析し、フィールドのインスタンスを生成します。
        /// <summary>
        /// 行の文字列を解析し、フィールドのインスタンスを生成します。
        /// </summary>
        /// <param name="line"></param>
        /// <param name="lines"></param>
        /// <returns></returns>
        private void ParseHeaderField(String line, List <String> lines)
        {
            Match         m    = RegexList.HeaderParse.Match(line);
            Match         m1   = null;
            Regex         rx   = RegexList.HeaderParse1;
            Field         f    = null;
            List <String> l    = lines;
            Int32         size = 0;

            for (int i = 0; i < lines.Count; i++)
            {
                size += line.Length;
            }
            StringBuilder sb = new StringBuilder(size);

            if (String.IsNullOrEmpty(m.Groups["key"].Value) == false)
            {
                m1 = rx.Match(m.Groups["value"].Value);
                if (m.Groups["key"].Value.ToLower() == "content-type" ||
                    m.Groups["key"].Value.ToLower() == "content-disposition")
                {
                    sb.Append(line);
                    for (int i = 0; i < l.Count; i++)
                    {
                        sb.Append(l[i].TrimStart('\t'));
                    }
                    this.ParseContentEncoding(sb.ToString());

                    if (m.Groups["key"].Value.ToLower() == "content-type")
                    {
                        MailParser.ParseContentType(this.ContentType, sb.ToString());
                        this.ContentType.Value = m1.Groups["value"].Value;
                    }
                    else if (m.Groups["key"].Value.ToLower() == "content-disposition")
                    {
                        MailParser.ParseContentDisposition(this.ContentDisposition, sb.ToString());
                        this.ContentDisposition.Value = m1.Groups["value"].Value;
                    }
                }
                else
                {
                    f = Field.FindField(this._Header, m.Groups["key"].Value);
                    if (f == null)
                    {
                        f = new Field(m.Groups["key"].Value, m.Groups["value"].Value);
                        this.Header.Add(f);
                    }
                    else
                    {
                        f.Value = m.Groups["value"].Value;
                    }
                    for (int i = 0; i < l.Count; i++)
                    {
                        f.Value += l[i].TrimStart('\t');
                    }
                }
            }
        }
        public void should_return_empty_DateAndTime()
        {
            const string text   = "Organize a remote meeting in Glazgo.";
            var          date   = new DateTime(2015, 1, 1);
            var          result = new MailParser().Parse(text, date);

            result.DateAndTime.Literal.Should().BeNullOrEmpty();
            result.DateAndTime.Expression.Should().BeNullOrEmpty();
        }
        public void should_parse_tomorrow()
        {
            const string text   = "Organize a remote meeting in Glazgo for us tomorrow.";
            var          date   = new DateTime(2015, 1, 1);
            var          result = new MailParser().Parse(text, date);

            result.DateAndTime.Literal.Should().Be("tomorrow");
            result.DateAndTime.Expression.Should().Be("2015-01-02");
        }
        public void TestAddressCollectionFolding(int addressCount, string source)
        {
            MailAddressCollection addresses = null;

            Assert.DoesNotThrow(() => addresses = MailParser.ParseAddressCollection(source));

            string foldedText = null;

            Assert.DoesNotThrow(() => foldedText = addresses.ToStringWithFolding());
            Assert.True(!string.IsNullOrEmpty(foldedText));

            string[] foldedParts = null;
            Assert.DoesNotThrow(() => foldedParts = foldedText.Split(new string[] { MailStandard.CRLF }, StringSplitOptions.None));
            this.CheckParts(foldedParts, addressCount);
        }
Ejemplo n.º 17
0
        /// Content-Encodingの解析を行います。
        /// <summary>
        /// Content-Encodingの解析を行います。
        /// </summary>
        /// <param name="line"></param>
        private void ParseContentEncoding(String line)
        {
            Match m = null;

            //charset=???;
            foreach (Regex rx in RegexList.ContentEncodingCharset)
            {
                m = rx.Match(line);
                if (String.IsNullOrEmpty(m.Groups["Value"].Value) == false)
                {
                    this._ContentEncoding = MailParser.GetEncoding(m.Groups["Value"].Value, this.ContentEncoding);
                    break;
                }
            }
        }
Ejemplo n.º 18
0
        public void ShouldDoBasicRoundTrip()
        {
            Message m = new Message();

            m.To      = new Header("To", "*****@*****.**");
            m.Subject = new Header("Subject", "Hello, world!");
            m.Body    = new Body("This is a test.");

            string  messageText = MimeSerializer.Default.Serialize(m);
            Message m2          = MailParser.ParseMessage(messageText);

            // TODO: Perhaps body is inserting a CRLF?
            Assert.Equal("This is a test.", m2.Body.Text.Trim());
            Assert.Equal("*****@*****.**", m2.To.Value);
            Assert.Equal("Hello, world!", m2.Subject.Value);
        }
Ejemplo n.º 19
0
        public void CheckDate()
        {
            Message m = new Message();

            m.To      = new Header("To", "*****@*****.**");
            m.Subject = new Header("Subject", "Hello, world!");
            m.Body    = new Body("This is a test.");

            m.Timestamp();
            Assert.True(m.HasHeader(MailStandard.Headers.Date));

            string  messageText = MimeSerializer.Default.Serialize(m);
            Message m2          = MailParser.ParseMessage(messageText);

            Assert.True(m.HasHeader(MailStandard.Headers.Date));
        }
Ejemplo n.º 20
0
        public void TestPrivateKeyLookupFailure()
        {
            string fileName    = "simple.eml";
            string messageText = m_tester.ReadMessageText(fileName);

            Message message = MailParser.ParseMessage(messageText);

            message.ToValue = "*****@*****.**";  // this should force a key lookup failure
            AgentTester.CheckErrorCode <AgentException, AgentError>(
                () => m_tester.AgentA.ProcessOutgoing(new OutgoingMessage(message)),
                AgentError.NoTrustedRecipients
                );

            DirectAgent badAgent = new DirectAgent(new StaticDomainResolver(m_tester.AgentA.Domains.Domains.ToArray()),
                                                   new NullResolver(), // returns null private certs
                                                   m_tester.AgentA.PublicCertResolver,
                                                   m_tester.AgentA.TrustAnchors);

            message = MailParser.ParseMessage(messageText);
            AgentTester.CheckErrorCode <AgentException, AgentError>(
                () => badAgent.ProcessOutgoing(new OutgoingMessage(message)),
                AgentError.CouldNotResolvePrivateKey
                );

            OutgoingMessage outgoing = m_tester.AgentA.ProcessOutgoing(messageText);

            badAgent = new DirectAgent(new StaticDomainResolver(m_tester.AgentB.Domains.Domains.ToArray()),
                                       new NullResolver(),            // returns null private certs
                                       m_tester.AgentB.PublicCertResolver,
                                       m_tester.AgentB.TrustAnchors);

            AgentTester.CheckErrorCode <AgentException, AgentError>(
                () => badAgent.ProcessIncoming(outgoing.SerializeMessage()),
                AgentError.CouldNotResolvePrivateKey
                );

            badAgent = new DirectAgent(new StaticDomainResolver(m_tester.AgentB.Domains.Domains.ToArray()),
                                       new NullResolver(true),            // returns empty private cert collections
                                       m_tester.AgentB.PublicCertResolver,
                                       m_tester.AgentB.TrustAnchors);

            AgentTester.CheckErrorCode <AgentException, AgentError>(
                () => badAgent.ProcessIncoming(outgoing.SerializeMessage()),
                AgentError.CouldNotResolvePrivateKey
                );
        }
Ejemplo n.º 21
0
        private void SetBodyData()
        {
            StringBuilder sb       = new StringBuilder(1024);
            String        bodyText = "";

            if (this.IsMultiPart == true)
            {
                for (int i = 0; i < this._Contents.Count; i++)
                {
                    sb.Append("--");
                    sb.Append(this.MultiPartBoundary);
                    sb.Append(MailParser.NewLine);
                    sb.Append(this._Contents[i].Data);
                    sb.Append(MailParser.NewLine);
                }
                sb.AppendFormat("--{0}--", this.MultiPartBoundary);
            }
            else
            {
                if (this.IsAttachment == true)
                {
                    bodyText = this.BodyText;
                }
                else
                {
                    bodyText = MailParser.EncodeToMailBody(this.BodyText, this.ContentTransferEncoding, this.ContentEncoding);
                }
                if (this.ContentTransferEncoding == TransferEncoding.SevenBit)
                {
                    sb.Append(bodyText);
                }
                else
                {
                    for (int i = 0; i < bodyText.Length; i++)
                    {
                        if (i > 0 &&
                            i % 76 == 0)
                        {
                            sb.Append(MailParser.NewLine);
                        }
                        sb.Append(bodyText[i]);
                    }
                }
            }
            this.BodyData = sb.ToString();
        }
Ejemplo n.º 22
0
        private static void Parse()
        {
            Params.GetParams();


            using (StreamWriter sw = new StreamWriter(Directory.GetCurrentDirectory() + "\\db.db", true, System.Text.Encoding.Default, 2048))
            {
                Console.WriteLine(@"[{0}]: Начало итерации", DateTime.Now.ToString());
                if (Params.Yandex == 1)
                {
                    YandexParser.Parse(sw);
                }
                Console.Write("10%");
                if (Params.Mail == 1)
                {
                    MailParser.Parse(sw);
                }
                Console.Write("20%");
                if (Params.AccuWeather == 1)
                {
                    AccuParser.Parse(sw);
                }
                Console.Write("30%");
                if (Params.Weather == 1)
                {
                    WeatherParser.Parse(sw);
                }
                Console.Write("40%");
                if (Params.GisMeteo == 1)
                {
                    GismeteoParser.Parse(sw);
                }
                Console.Write("50%");
                if (Params.Fobos == 1)
                {
                    FobosParser.Parse(sw);
                }
                Console.Write("60%");
                if (Params.Foreca == 1)
                {
                    ForecaParser.Parse(sw);
                }
                Console.WriteLine("100%");
                Console.WriteLine(@"[{0}]: Итерация закончена", DateTime.Now.ToString());
            }
        }
Ejemplo n.º 23
0
        public AktionForm(Konfiguration cfg, Logger log, Language lang, MailParser mp)
        {
            InitializeComponent();

            this.mailparser = mp;

            this.config = cfg;
            this.loadFromConfig();

            this.logger = log;

            this.language = lang;
            this.loadFromLanguage();

            this.tB_afterTrainSpam_MoveTo.Enabled     = this.rB_afterTrainSpam_MoveTo.Checked;
            this.tB_afterTrainSpam_PrefixWith.Enabled = this.cB_afterTrainSpam_PrefixWith.Checked;
            this.tB_afterTrainHam_MoveTo.Enabled      = this.rB_afterTrainHam_MoveTo.Checked;
            this.tB_afterTrainHam_PrefixWith.Enabled  = this.cB_afterTrainHam_PrefixWith.Checked;
        }
Ejemplo n.º 24
0
        public void TestMissingMdn()
        {
            CleanMessages(m_agent.Settings);
            m_agent.Settings.InternalMessage.EnableRelay = true;
            m_agent.Settings.Notifications.AutoResponse  = true;
            m_agent.Settings.Notifications.AlwaysAck     = true;
            m_agent.Settings.MdnMonitor     = new ClientSettings();
            m_agent.Settings.MdnMonitor.Url = "http://localhost:6692/MonitorService.svc/Dispositions";

            string textMessage = string.Format(TestMessageTimelyAndReliableMissingTo, Guid.NewGuid());
            //
            // RequestNotification needed to use the CreateNotificationMessages
            //
            var mailMessage = MailParser.ParseMessage(textMessage);

            mailMessage.RequestNotification();
            textMessage = mailMessage.ToString();
            var incoming = new IncomingMessage(textMessage);

            List <NotificationMessage> notificationMessages = GetNotificationMessages(incoming, MDNStandard.NotificationType.Processed);

            Assert.True(notificationMessages.Count == 2);
            RunMdnProcessingForMissingStart(notificationMessages);

            notificationMessages = GetNotificationMessages(incoming, MDNStandard.NotificationType.Dispatched);
            Assert.True(notificationMessages.Count == 2);
            RunMdnProcessingForMissingStart(notificationMessages);

            notificationMessages = GetNotificationMessages(incoming, MDNStandard.NotificationType.Failed);
            Assert.True(notificationMessages.Count == 2);
            RunMdnProcessingForMissingStart(notificationMessages);

            notificationMessages = GetNotificationMessages(incoming, MDNStandard.NotificationType.Displayed); //No currently using.
            Assert.True(notificationMessages.Count == 2);
            RunMdnProcessingForMissingStart(notificationMessages);

            notificationMessages = GetNotificationMessages(incoming, MDNStandard.NotificationType.Deleted); //No currently using.
            Assert.True(notificationMessages.Count == 2);
            RunMdnProcessingForMissingStart(notificationMessages);


            m_agent.Settings.InternalMessage.EnableRelay = false;
        }
Ejemplo n.º 25
0
        public MainForm(Konfiguration cfg, Logger log, Language lang, MailParser mp, Outlook.Application objOutlook, Worker w)
        {
            InitializeComponent();

            this.worker  = w;
            this.outlook = objOutlook;

            this.mailparser = mp;

            this.config = cfg;
            this.loadFromConfig();

            this.logger = log;

            this.language = lang;
            this.loadFromLanguage();

            this.bt_sendLogToDeveloper.Visible = false;
            this.bt_thankYou.Visible           = false;
        }
Ejemplo n.º 26
0
        /// SMTPメールサーバーへCRAM-MD5認証でログインします。
        /// <summary>
        /// SMTPメールサーバーへCRAM-MD5認証でログインします。
        /// </summary>
        /// <returns></returns>
        public Boolean AuthenticateByCramMD5()
        {
            SmtpCommandResult rs = null;

            if (this.EnsureOpen() == SmtpConnectionState.Connected)
            {
                rs = this.Execute("Auth CRAM-MD5");
                if (rs.StatusCode != SmtpCommandResultCode.WaitingForAuthentication)
                {
                    return(false);
                }
                //ユーザー名+チャレンジ文字列をBase64エンコードした文字列を送信
                String s = MailParser.ToCramMd5String(rs.Message, this.UserName, this.Password);
                rs = this.Execute(s);
                if (rs.StatusCode == SmtpCommandResultCode.AuthenticationSuccessful)
                {
                    this._State = SmtpConnectionState.Authenticated;
                }
            }
            return(this._State == SmtpConnectionState.Authenticated);
        }
Ejemplo n.º 27
0
        static DSNMessage CreateNotificationMessage(Mdn mdn, TimeoutSettings settings)
        {
            var perMessage   = new DSNPerMessage(settings.ProductName, mdn.MessageId);
            var perRecipient = new DSNPerRecipient(DSNStandard.DSNAction.Failed, DSNStandard.DSNStatus.Permanent
                                                   , DSNStandard.DSNStatus.NETWORK_EXPIRED_PROCESSED,
                                                   MailParser.ParseMailAddress(mdn.Recipient));
            //
            // The nature of Mdn storage in config store does not result in a list of perRecipients
            // If you would rather send one DSN with muliple recipients then one could write their own Job.
            //
            var notification = new DSN(perMessage, new List <DSNPerRecipient> {
                perRecipient
            });
            var sender = new MailAddress(mdn.Sender);
            var notificationMessage = new DSNMessage(sender.Address, new MailAddress("Postmaster@" + sender.Host).Address, notification);

            notificationMessage.AssignMessageID();
            notificationMessage.SubjectValue = string.Format("{0}:{1}", "Rejected", mdn.SubjectValue);
            notificationMessage.Timestamp();
            return(notificationMessage);
        }
Ejemplo n.º 28
0
        public TrainingForm(Konfiguration cfg, Logger log, Language lang, MailParser mp)
        {
            InitializeComponent();

            this.mailparser = mp;

            this.config = cfg;
            this.loadFromConfig();

            this.logger = log;

            this.language = lang;
            this.loadFromLanguage();

            this.tB_enterFolderForHam.Enabled    = this.cB_useAutoTrain.Checked;
            this.tB_enterFolderForSpam.Enabled   = this.cB_useAutoTrain.Checked;
            this.tB_enterForwardForHam.Enabled   = this.rB_trainWithForward.Checked;
            this.tB_enterForwardForSpam.Enabled  = this.rB_trainWithForward.Checked;
            this.tB_enterLoginOfDSpam.Enabled    = this.rB_trainWithWebUI.Checked;
            this.tB_enterPasswordOfDSpam.Enabled = this.rB_trainWithWebUI.Checked;
            this.tB_enterUrlOfDSpam.Enabled      = this.rB_trainWithWebUI.Checked;
        }
Ejemplo n.º 29
0
        public void DecodeData(String filePath)
        {
            Byte[] bb = null;

            if (String.IsNullOrEmpty(this.ContentDisposition.Value) == true)
            {
                return;
            }

            if (this.ContentTransferEncoding == TransferEncoding.Base64)
            {
                bb = Convert.FromBase64String(this.BodyData.Replace("\n", "").Replace("\r", ""));
                using (BinaryWriter sw = new BinaryWriter(new FileStream(filePath, FileMode.Create)))
                {
                    sw.Write(bb);
                    sw.Flush();
                    sw.Close();
                }
            }
            else if (this.ContentTransferEncoding == TransferEncoding.QuotedPrintable)
            {
                using (StreamWriter sw = File.CreateText(filePath))
                {
                    sw.Write(this.ContentEncoding.GetString(MailParser.FromQuotedPrintableText(this.BodyData)));
                    sw.Flush();
                    sw.Close();
                }
            }
            else if (this.ContentTransferEncoding == TransferEncoding.SevenBit)
            {
                bb = Encoding.ASCII.GetBytes(this.BodyData);
                using (BinaryWriter sw = new BinaryWriter(new FileStream(filePath, FileMode.Create)))
                {
                    sw.Write(bb);
                    sw.Flush();
                    sw.Close();
                }
            }
        }
Ejemplo n.º 30
0
        public Smtp.SmtpMessage CreateSmtpMessage()
        {
            Smtp.SmtpMessage mg = new Clover.Net.Smtp.SmtpMessage();
            Field            f  = null;

            mg.To.AddRange(MailAddress.CreateMailAddressList(this.To));
            mg.Cc.AddRange(MailAddress.CreateMailAddressList(this.Cc));
            for (int i = 0; i < this.Header.Count; i++)
            {
                f = this.Header[i];
                if (String.IsNullOrEmpty(f.Value) == true)
                {
                    continue;
                }
                if (f.Key.ToLower() == "to" ||
                    f.Key.ToLower() == "cc")
                {
                    continue;
                }
                mg[f.Key] = MailParser.DecodeFromMailHeaderLine(f.Value);
            }
            for (int i = 0; i < this.ContentType.Fields.Count; i++)
            {
                f = this.ContentType.Fields[i];
                mg.ContentType.Fields.Add(new Field(f.Key, MailParser.DecodeFromMailHeaderLine(f.Value)));
            }
            for (int i = 0; i < this.ContentDisposition.Fields.Count; i++)
            {
                f = this.ContentDisposition.Fields[i];
                mg.ContentDisposition.Fields.Add(new Field(f.Key, MailParser.DecodeFromMailHeaderLine(f.Value)));
            }
            mg.BodyText = this.BodyText;
            for (int i = 0; i < this.Contents.Count; i++)
            {
                mg.Contents.Add(this.Contents[i].CreateSmtpContent());
            }
            return(mg);
        }