Getting an unexpected response from somewhere outside of my SMTP server program

I am currently working on creating my own SMTP server for the project I'm working on.

This all works very hard, except that when I enter the data, I get a response from something else that is not my program.

To run the test, I run my program, which binds to IPAddress.Any and to port 25 for smtp. I am using telnet from my local PC to verify that I am sending the correct answers. By doing this, I turned on debugging and ran the code to find out what my program was doing.

  • When I connect, send a message 220 with my domain name
  • When telnet sends EHLO, I send back250 with my domain name
  • From telnet I send MAIL FROM: someone@fromaddress.comand I send back250 2.1.0 OK
  • From telnet I send RCPT TO: someone@toaddress.comand I send back250 2.1.5 OK

Now strange things happen here, From telnet I send DATAfor the main email, and in the code I have to send 354 End data with <CR><LF>.<CR><LF>, but instead I get a response354 please start mail input.

From all the steps until the visual data studio went into debugging mode so that I could go through, but when I entered DATA, the visual studio did not respond as if my program was not receiving anything, and instead it went somewhere else.

I have no idea where this comes from, I do not have another SMTP server running on my PC.

Below is the code I'm using

private void processSmtpReceived(TcpClient client)
        {
            stream = client.GetStream();
            reader = new StreamReader(stream);
            writer = new StreamWriter(stream);
            writer.NewLine = "\r\n";
            writer.AutoFlush = true;

            //writer.WriteLine("220 localhost -- Fake proxy server");
            string line = "";
            string message = "";
            string subject = "";
            bool readingData = false;
            if (client.Connected)
            {
                writer.WriteLine("220 localhost -- Fake proxy server");

                while ((line = reader.ReadLine()) != null && reader != null)
                {
                    line = line.Replace("\b", "");
                    if (readingData)
                    {
                        message += line;
                        if (line.Contains("Subject:"))
                        {
                            subject = line;
                        }
                        else if (line == ".")
                        {
                            writer.WriteLine("250 2.0.0 OK");
                            readingData = false;
                        }
                    }
                    else if (line.Contains("EHLO"))
                    {
                        writer.WriteLine("250 OK localhost-workgroup");
                    }
                    else if (line.Contains("MAIL FROM"))
                    {
                        writer.WriteLine("250 2.1.0 OK");
                    }
                    else if (line.Contains("RCPT TO"))
                    {
                        writer.WriteLine("250 2.1.5 OK");
                    }
                    else if (line.Contains("DATA"))
                    {
                        writer.WriteLine("354 End data with <CR><LF>.<CR><LF>");
                        readingData = true;
                    }
                    else if (line == ".")
                    {
                        writer.WriteLine("250 2.0.0 OK");
                    }
                    else if (line == "QUIT")
                    {
                        writer.WriteLine("221 2.0.0 Bye");
                        Console.WriteLine("Message: " + message);
                    }
                    else
                    {
                        writer.WriteLine("250 OK");
                    }
                    Console.WriteLine("Received: {0}", line);
                }
            }

As you can see from the code, the answer is start mail inputmissing in my code, so I don’t know where it comes from.

Thanks for any help you can provide.

UPDATE -, . SMTP- telnet , telnet localhost 25 , 354 <CR><LF>.<CR><LF>, , telnet , telnet 192.168.1.74 25, 354 please start mail input, , Windows Linux, , , , , , smtp, , telnet 25. .

2 , telnet DATA , MYTEST, MYTEST, , , , , DATA, SMTP, , - . , , - , SMTP- - , .

3 , , DATA, telnet, - Windows Windows. telnet linux smtp, Windows, , Windows - , DATA.

4 , Windows, . Windows 7, telnet , localhost, , telnet dev- , , . , -, - SMTP-, , , , 25. , Symantec Norton 360, , .

+5
1

. , Symantec Norton 360, , , DATA smtp-. - norton, , , . , 25, , , . , smtp, , 26, .

.

0

All Articles