Socket soket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
soket.Connect("gmail-smtp-in.l.google.com", 25);
string addToEnd= "\r\n";
byte[] dataBuffer;
string answer;
NetworkStream netStream = new NetworkStream(soket);
StreamReader reader = new StreamReader(netStream);
answer = reader.ReadLine();
dataBuffer = BytesFromString("HELO Vlada" + addToEnd);
netStream.Write(dataBuffer, 0, dataBuffer.Length);
answer = reader.ReadLine();
// NEXT CODE is for login but after that i get 502 5.5.1 Unrecognized command. i42si28816556eem.28
dataBuffer = BytesFromString("AUTH LOGIN someUsername" + dodatakNaKraju);
netStream.Write(dataBuffer,0,dataBuffer.Length);
answer = reader.ReadLine();
所以登录失败。该方法BytesFromString
只是将 STRING 转换为 ASCII 字节。
我需要它来考试。