Ejemplo n.º 1
0
        private void Data(SmtpContext context)
        {
            context.WriteLine(MESSAGE_START_DATA);

            MailMessage message = context.Message;

            //IPEndPoint clientEndPoint = (IPEndPoint) context.Socket.RemoteEndPoint;
            //IPEndPoint localEndPoint = (IPEndPoint) context.Socket.LocalEndPoint;

            StringBuilder header = new StringBuilder();

            header.Append("Received: from " + context.ClientDomain + " (" + context.ClientDomain + " [" + context.RemoteEndPoint.Address + "])");
            header.Append("\r\n");
            header.Append("     by " + context.LocalEndPoint.Address);
            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");

                if (line.Length == 0)
                {
                    message.SetEndOfHeader();
                }

                line = context.ReadLine();
            }

            string spoolError;

            if (message == null || _storage.SpoolMessage(context.RemoteEndPoint, message.ToAddress, message.Message, out spoolError))
            {
                context.WriteLine(MESSAGE_OK);
            }
            else
            {
                if (spoolError != null && spoolError.Length > 0)
                {
                    context.Write("554");
                    context.WriteLine(spoolError);
                }
                else
                {
                    context.WriteLine(MESSAGE_SYSTEM_ERROR);
                }
            }

            context.Reset();
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Reset the connection state.
 /// </summary>
 private void Rset(SmtpContext context)
 {
     if (context.LastCommand != -1)
     {
         context.Reset();
         context.WriteLine(MESSAGE_OK);
     }
     else
     {
         context.WriteLine(MESSAGE_INVALID_COMMAND_ORDER);
     }
 }