0
連接復位可以說我有一個功能,像下面發送和從完美套接字接收到的信息..發送電子郵件:通過對
的結果是:
Connected to: 65.55.96.11 Port: 25
220 BLU0-SMTP374.blu0.hotmail.com Microsoft ESMTP MAIL Service, Version: 6.0.3790.4675 ready at Mon, 31 Dec 2012 19:52:22 -0800
250 BLU0-SMTP374.blu0.hotmail.com Hello [50.100.44.155]
220 2.0.0 SMTP server ready
Exception: Socket Error 10054: Connection reset by peer
爲什麼我得到一個異常?它會在發送「DATA」字符串時引發異常。
如何登錄?我似乎無法找到網上的任何地方。我搜索了它,只看到了AUTH命令,但根本沒有使用或示例。
的代碼如下:
void SendEmail(std::string Username, std::string Password, std::string IP, std::string Port)
{
Socket = CreateSocket;
ConnectSocket(Socket, IP, Port);
SetTimeout(Socket, 10000);
SocketInfo(Socket, IP, Port);
writeln("Connected to: " + IP + " Port: " + Port);
writeln(RecvSocket(Socket));
SendSocketEx(Socket, "HELO"); //SendSocketEx automatically adds \r\n to the end of a line..
writeln(RecvSocket(Socket));
SendSocketEx(Socket, "STARTTLS");
writeln(RecvSocket(Socket));
SendSocketEx(Socket, "MAIL FROM: [email protected]");
writeln(RecvSocket(Socket));
SendSocketEx(Socket, "VRFY [email protected]");
writeln(RecvSocket(Socket));
SendSocketEx(Socket, "RCPT TO: [email protected]");
writeln(RecvSocket(Socket));
SendSocketEx(Socket, "DATA");
writeln(RecvSocket(Socket));
SendSocketEx(Socket, "This Is The Body..");
writeln(RecvSocket(Socket));
SendSocketEx(Socket, "QUIT");
writeln(RecvSocket(Socket));
CloseSocket(Socket);
FreeSocket(Socket);
}
int main()
{
SendEmail("", "", "smtp.live.com", "25", "localhost");
}
「我有一個函數像下面發送和接收信息從一個插座完美無瑕..「 - 呃,如果它拋出一個異常,它怎麼會是無瑕的? –
因爲它發送和接收數據就好了。我只是無法弄清楚如何登錄..它會拋出一個異常,因爲無法發送。我認爲這是認證是原因?它發送了第一對夫婦的命令,並收到了答覆:l – Brandon