コード例 #1
0
        public void SetUp()
        {
            theSession = MockRepository.GenerateStub<ISmtpSession>();
            theHandler = new HeloHandler();
            theToken = new SmtpToken();

            theSession.Stub(x => x.RemoteAddress).Return("1234");
        }
コード例 #2
0
        public void SetUp()
        {
            theSession = MockRepository.GenerateStub <ISmtpSession>();
            theHandler = new HeloHandler();
            theToken   = new SmtpToken();

            theSession.Stub(x => x.RemoteAddress).Return("1234");
        }
コード例 #3
0
        public ContinueProcessing Handle(SmtpToken token, ISmtpSession session)
        {
            if(token.Command == Recipient)
            {
                var rawAddress = token.Data.ValueFromAttributeSyntax(); // <*****@*****.**>
                session.AddRecipient(rawAddress.Replace("<", "").Replace(">", ""));
            }

            session.WriteResponse("250 Ok");
            return ContinueProcessing.Continue;
        }
コード例 #4
0
        public ContinueProcessing Handle(SmtpToken token, ISmtpSession session)
        {
            if (token.Command == Recipient)
            {
                var rawAddress = token.Data.ValueFromAttributeSyntax(); // <*****@*****.**>
                session.AddRecipient(rawAddress.Replace("<", "").Replace(">", ""));
            }

            session.WriteResponse("250 Ok");
            return(ContinueProcessing.Continue);
        }
コード例 #5
0
        public ContinueProcessing Handle(SmtpToken token, ISmtpSession session)
        {
            _messageGatherer.AppendLine(token.Data);

            if (token.Data != null && token.Data.Trim() == ".")
            {
                session.WriteResponse(string.Format("250 Ok: queued as {0}", Guid.NewGuid()));
                session.SaveMessage(CreateMessage(_messageGatherer, session));
                token.IsMessageBody = false;
            }

            return(ContinueProcessing.Continue);
        }
コード例 #6
0
        public MailMessage CreateMessage(StringBuilder builder, ISmtpSession session)
        {
            var message = new MessageParser().Parse(builder.ToString());

            // Any recipients that are registered but haven't been used are blind copies
            session
                .Recipients
                .Where(x => !message.To.Any(y => y.Address == x) && !message.CC.Any(y => y.Address == x))
                .Each(x => message.Bcc.Add(x));


            return message;
        }
コード例 #7
0
        public ContinueProcessing Handle(SmtpToken token, ISmtpSession session)
        {
            _messageGatherer.AppendLine(token.Data);

            if(token.Data != null && token.Data.Trim() == ".")
            {
                session.WriteResponse(string.Format("250 Ok: queued as {0}", Guid.NewGuid()));
                session.SaveMessage(CreateMessage(_messageGatherer, session));
                token.IsMessageBody = false;
            }

            return ContinueProcessing.Continue;
        }
コード例 #8
0
        public MailMessage CreateMessage(StringBuilder builder, ISmtpSession session)
        {
            var message = new MessageParser().Parse(builder.ToString());

            // Any recipients that are registered but haven't been used are blind copies
            session
            .Recipients
            .Where(x => !message.To.Any(y => y.Address == x) && !message.CC.Any(y => y.Address == x))
            .Each(x => message.Bcc.Add(x));


            return(message);
        }
コード例 #9
0
        public void SetUp()
        {
            theHandler = new MessageParsingHandler();

            theMessageBody = new StringBuilder();
            theMessageBody.AppendLine("MIME-Version: 1.0");
            theMessageBody.AppendLine("From: [email protected]");
            theMessageBody.AppendLine("To: [email protected], [email protected]");
            theMessageBody.AppendLine("Cc: [email protected]");
            theMessageBody.AppendLine("Subject: This is a test");
            theMessageBody.AppendLine("Content-Type: text/plain; charset=us-ascii");
            theMessageBody.AppendLine("Content-Transfer-Encoding: quoted-printable");
            theMessageBody.AppendLine();
            theMessageBody.AppendLine("This is the body");
            theMessageBody.AppendLine().AppendLine(".").AppendLine();

            theRecipients = new List <string>();
            theSession    = MockRepository.GenerateStub <ISmtpSession>();

            theSession.Stub(x => x.Recipients).Return(theRecipients);

            theMessage = theHandler.CreateMessage(theMessageBody, theSession);
        }
コード例 #10
0
        public void SetUp()
        {
            theHandler = new MessageParsingHandler();

            theMessageBody = new StringBuilder();
            theMessageBody.AppendLine("MIME-Version: 1.0");
            theMessageBody.AppendLine("From: [email protected]");
            theMessageBody.AppendLine("To: [email protected], [email protected]");
            theMessageBody.AppendLine("Cc: [email protected]");
            theMessageBody.AppendLine("Subject: This is a test");
            theMessageBody.AppendLine("Content-Type: text/plain; charset=us-ascii");
            theMessageBody.AppendLine("Content-Transfer-Encoding: quoted-printable");
            theMessageBody.AppendLine();
            theMessageBody.AppendLine("This is the body");
            theMessageBody.AppendLine().AppendLine(".").AppendLine();

            theRecipients = new List<string>();
            theSession = MockRepository.GenerateStub<ISmtpSession>();

            theSession.Stub(x => x.Recipients).Return(theRecipients);

            theMessage = theHandler.CreateMessage(theMessageBody, theSession);
        }
コード例 #11
0
 public ContinueProcessing Handle(SmtpToken token, ISmtpSession session)
 {
     session.WriteResponse("221 Bye");
     return(ContinueProcessing.Stop);
 }
コード例 #12
0
 public void SetUp()
 {
     theSession = MockRepository.GenerateStub<ISmtpSession>();
     theHandler = new QuitHandler();
     theToken = new SmtpToken();
 }
コード例 #13
0
 public void SetUp()
 {
     theSession = MockRepository.GenerateStub <ISmtpSession>();
     theHandler = new RegisterAddressesHandler();
     theToken   = new SmtpToken();
 }
コード例 #14
0
 public ContinueProcessing Handle(SmtpToken token, ISmtpSession session)
 {
     session.WriteResponse("354 End data with .");
     token.IsMessageBody = true;
     return(ContinueProcessing.Continue);
 }
コード例 #15
0
 public void SetUp()
 {
     theSession = MockRepository.GenerateStub<ISmtpSession>();
     theHandler = new RegisterAddressesHandler();
     theToken = new SmtpToken();
 }
コード例 #16
0
 public ContinueProcessing Handle(SmtpToken token, ISmtpSession session)
 {
     session.WriteResponse(string.Format("250 Hello {0}, I am glad to meet you", session.RemoteAddress));
     return ContinueProcessing.Continue;
 }
コード例 #17
0
 public ContinueProcessing Handle(SmtpToken token, ISmtpSession session)
 {
     session.WriteResponse("221 Bye");
     return ContinueProcessing.Stop;
 }
コード例 #18
0
 public ContinueProcessing Handle(SmtpToken token, ISmtpSession session)
 {
     session.WriteResponse("354 End data with .");
     token.IsMessageBody = true;
     return ContinueProcessing.Continue;
 }
コード例 #19
0
 public ContinueProcessing Handle(SmtpToken token, ISmtpSession session)
 {
     session.WriteResponse(string.Format("250 Hello {0}, I am glad to meet you", session.RemoteAddress));
     return(ContinueProcessing.Continue);
 }
コード例 #20
0
 public void SetUp()
 {
     theSession = MockRepository.GenerateStub <ISmtpSession>();
     theHandler = new DataHandler();
     theToken   = new SmtpToken();
 }