Пример #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();
        }
Пример #2
0
        private void Data(SMTPContext context)
        {
            context.WriteLine(MESSAGE_START_DATA);

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

            data.Append(String.Format("Received: from {0} ({0} [{1}])", context.ClientDomain, clientEndPoint.Address));
            data.Append("\r\n");
            data.Append(String.Format("     by {0} (Age of Wonders Email Wrapper)", domain));
            data.Append("\r\n");
            data.Append("     " + System.DateTime.Now);
            data.Append("\r\n");

            String line = context.ReadLine();

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

            context.Message = new MailBuilder().CreateFromEml(data.ToString());

            // Spool the message
            if (messageSpool == null)
            {
                //If no spooler set
                context.WriteLine(MESSAGE_OK);
            }
            else if (messageSpool.SpoolMessage(context.Message))
            {
                context.WriteLine(MESSAGE_OK);
            }
            else
            {
                context.WriteLine(MESSAGE_SYSTEM_ERROR);
            }

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