コード例 #1
0
        private void Data(SmtpContext context)
        {
            context.WriteLine(MESSAGE_START_DATA);

            SmtpMessage   message        = context.Message;
            IPEndPoint    clientEndPoint = (IPEndPoint)context.Socket.RemoteEndPoint;
            StringBuilder header         = new StringBuilder();

            header.Append(String.Format("Received: from ({0} [{1}])", context.ClientDomain, clientEndPoint.Address));
            header.Append("\r\n");
            header.Append("     " + System.DateTime.Now);
            header.Append("\r\n");

            message.AddData(header.ToString());

            header.Length = 0;

            String line = context.ReadLine();

            while (!line.Equals("."))
            {
                message.AddData(line);
                message.AddData("\r\n");
                line = context.ReadLine();
            }

            // Spool the message
            lock (messageSpool)
                messageSpool.Add(message);

            context.WriteLine(MESSAGE_OK);

            // Reset the connection.
            context.Reset();
        }
コード例 #2
0
ファイル: SmtpContext.cs プロジェクト: DocLeon/netDumbster
 /// <summary>
 /// Resets this context for a new message
 /// </summary>
 public void Reset()
 {
     _Log.Debug("Resetting SmtpContext.");
     inputBuffer.Length = 0;
     message            = new SmtpMessage();
     lastCommand        = SmtpProcessor.COMMAND_HELO;
     _Log.Debug("Done resetting SmtpContext.");
 }
コード例 #3
0
        /// <summary>
        /// Initialize this context for a given socket connection.
        /// </summary>
        public SmtpContext(Socket socket)
        {
            this.lastCommand = -1;
            this.socket = socket;
            message = new SmtpMessage();

            // Set the encoding to ASCII.
            encoding = Encoding.ASCII;

            // Initialize the input buffer
            inputBuffer = new StringBuilder();
        }
コード例 #4
0
ファイル: SmtpContext.cs プロジェクト: DocLeon/netDumbster
        /// <summary>
        /// Initialize this context for a given socket connection.
        /// </summary>
        public SmtpContext(Socket socket)
        {
            this.lastCommand = -1;
            this.socket      = socket;
            message          = new SmtpMessage();

            // Set the encoding to ASCII.
            encoding = Encoding.ASCII;

            // Initialize the input buffer
            inputBuffer = new StringBuilder();
        }
コード例 #5
0
        private void Data(SmtpContext context)
        {
            context.WriteLine(MESSAGE_START_DATA);

            RawSmtpMessage rawSmtpMessage = context.Message;

            IPEndPoint    clientEndPoint = (IPEndPoint)context.Socket.RemoteEndPoint;
            StringBuilder header         = new StringBuilder();

            header.Append(string.Format("Received: from ({0} [{1}])", context.ClientDomain, clientEndPoint.Address));
            header.Append("\r\n");
            header.Append("     " + System.DateTime.Now);
            header.Append("\r\n");

            rawSmtpMessage.Data.Append(header.ToString());

            header.Length = 0;

            string line = context.ReadLine();

            while (!line.Equals("."))
            {
                rawSmtpMessage.Data.Append(line);
                rawSmtpMessage.Data.Append("\r\n");
                line = context.ReadLine();
            }

            // Spool the message
            lock (this.smtpMessageStore)
            {
                SmtpMessage smtpMessage = new SmtpMessage(rawSmtpMessage);
                if (this.smtpMessageStore != null)
                {
                    this.smtpMessageStore.Add(smtpMessage);
                }

                if (this.MessageReceived != null)
                {
                    this.MessageReceived(this, new MessageReceivedArgs(smtpMessage));
                }
            }

            context.WriteLine(MESSAGE_OK);

            // Reset the connection.
            context.Reset();
        }
コード例 #6
0
 /// <summary>
 /// Resets this context for a new message
 /// </summary>
 public void Reset()
 {
     _Log.Debug("Resetting SmtpContext.");
     inputBuffer.Length = 0;
     message = new SmtpMessage();
     lastCommand = SmtpProcessor.COMMAND_HELO;
     _Log.Debug("Done resetting SmtpContext.");
 }
コード例 #7
0
        private void Data(SmtpContext context)
        {
            context.WriteLine(MESSAGE_START_DATA);

            RawSmtpMessage rawSmtpMessage = context.Message;

            IPEndPoint clientEndPoint = (IPEndPoint)context.Socket.RemoteEndPoint;
            StringBuilder header = new StringBuilder();
            header.Append(string.Format("Received: from ({0} [{1}])", context.ClientDomain, clientEndPoint.Address));
            header.Append("\r\n");
            header.Append("     " + System.DateTime.Now);
            header.Append("\r\n");

            rawSmtpMessage.Data.Append(header.ToString());

            header.Length = 0;

            string line = context.ReadLine();
            while (!line.Equals("."))
            {
                rawSmtpMessage.Data.Append(line);
                rawSmtpMessage.Data.Append("\r\n");
                line = context.ReadLine();
            }

            // Spool the message
            lock (this.smtpMessageStore)
            {
                SmtpMessage smtpMessage = new SmtpMessage(rawSmtpMessage);
                if (this.smtpMessageStore != null)
                {
                    this.smtpMessageStore.Add(smtpMessage);
                }

                if (this.MessageReceived != null)
                {
                    this.MessageReceived(this, new MessageReceivedArgs(smtpMessage));
                }
            }

            context.WriteLine(MESSAGE_OK);

            // Reset the connection.
            context.Reset();
        }
コード例 #8
0
 public MessageReceivedArgs(SmtpMessage message)
 {
     Message = message;
 }