/// <summary> /// Initialize this context for a given socket connection. /// </summary> public SmtpContext(long connectionId, Socket socket, ILog logger) { _logger = logger ?? new NullLogger(); _logger.Debug("Connection {0}: New connection from client {1}", connectionId, socket.RemoteEndPoint); _connectionId = connectionId; _lastCommand = -1; _socket = socket; _messageData = new SmtpMessageData(); // Set the encoding to ASCII. _encoding = Encoding.ASCII; // Initialize the input buffer _inputBuffer = new StringBuilder(); }
/// <summary> /// Resets this context for a new message /// </summary> public void Reset() { _logger.Debug("Connection {0}: Reset", _connectionId); _messageData = new SmtpMessageData(); _lastCommand = SmtpHandler.CommandHelo; }
public void BodyBase64() { var messageData = new SmtpMessageData { FromAddress = new MailAddress("*****@*****.**") }; messageData.AddData(TestBodyBase64); var message = messageData.ParseMessage(); message.Attachments.Count.ShouldEqual(1); new BinaryReader(message.Attachments[0].ContentStream).ReadBytes((int)message.Attachments[0].ContentStream.Length).ShouldEqual(Attachment1BodyData); message.Attachments[0].ContentType.MediaType.ShouldEqual("application/pdf"); message.Attachments[0].ContentDisposition.DispositionType.ShouldEqual("attachment"); message.Attachments[0].Name.ShouldEqual("000000002.pdf"); }
public void MessageHeaders() { var messageData = new SmtpMessageData { FromAddress = new MailAddress("*****@*****.**") }; messageData.AddData(TestSingleBase64); var message = messageData.ParseMessage(); message.Headers["Received"].ShouldEqual("from development02 (development02 [127.0.0.1]) by adexs.com (Eric Daugherty's C# Email Server) 4/16/2004 10:35:58 AM"); message.Headers["From"].ShouldEqual("\"Eric Daugherty\" <*****@*****.**>"); message.Subject.ShouldEqual("CofAs"); message.Headers["Date"].ShouldEqual("Fri, 16 Apr 2004 10:35:55 -0500"); message.Headers["X-MimeOLE"].ShouldEqual("Produced By Microsoft MimeOLE V6.00.2800.1409"); }