Exemplo n.º 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} ({0} [{1}])", context.ClientDomain, clientEndPoint.Address));
            header.Append("\r\n");
            header.Append(String.Format("     by {0} (Eric Daugherty's C# Email Server)", domain));
            header.Append("\r\n");
            header.Append("     " + System.DateTime.Now);
            header.Append("\r\n");

            message.AddData(header.ToString());

            String line = context.ReadLine();

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

            // Spool the message
            messageSpool.SpoolMessage(message);
            context.WriteLine(MESSAGE_OK);

            // Reset the connection.
            context.Reset();
        }