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(); }
/// <summary> /// Resets this context for a new message /// </summary> public void Reset() { if (log.IsDebugEnabled) { log.Debug(String.Format("Connection {0}: Reset", connectionId)); } message = new SMTPMessage(); lastCommand = SMTPProcessor.COMMAND_HELO; }
/// <summary> /// Initialize this context for a given socket connection. /// </summary> public SMTPContext(long connectionId, Socket socket) { if (log.IsDebugEnabled) { log.Debug(String.Format("Connection {0}: New connection from client {1}", connectionId, socket.RemoteEndPoint)); } this.connectionId = connectionId; this.lastCommand = -1; this.socket = socket; message = new SMTPMessage(); // Set the encoding to ASCII. encoding = Encoding.ASCII; // Initialize the input buffer inputBuffer = new StringBuilder(); }
/// <summary> /// Not Implemented. /// </summary> /// <remarks> /// Interface method from IMessageSpool. /// </remarks> /// <param name='message'>The message to spool.</param> public virtual bool SpoolMessage(SMTPMessage message) { throw new System.NotImplementedException(); }
/// <summary> /// Addes the message to the in memory queue. /// </summary> /// <param name='message'>The message to queue.</param> public virtual bool SpoolMessage(SMTPMessage message) { queue.Enqueue(message); return(true); }