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 バイトに変換するだけです。
試験に必要です。