0
我正在unix機器上使用C++製作一個smtp客戶端。我能夠收到運行程序的電子郵件,但在從服務器收到的消息之間缺少客戶端的輸出。我真的可以用一些幫助來閱讀這些消息。C++ unix smtp客戶端
我傳遞:服務器名稱,來自電子郵件,目標電子郵件,主題和消息。
write (socketNO, "HELO ", 5);
write (socketNO, argv[1], strlen(argv[1]));
write (socketNO, " ", 1);
write (socketNO, "\n", 1);
/* Address the mail is coming from */
write (socketNO, "MAIL FROM:<", 11);
write (socketNO, argv[2], strlen(argv[2]));
write (socketNO, ">", 1);
write (socketNO, "\n", 1);
/* Address the mail is going to */
write (socketNO, "RCPT TO:<", 9);
write (socketNO, argv[3], strlen(argv[3]));
write (socketNO, ">", 1);
write (socketNO, "\n", 1);
/* Says you are about to start the message & waits for servers OK */
write (socketNO, "DATA", 5);
write (socketNO, "\n", 1);
/* Writes the subject and the message */
write (socketNO, "SUBJECT: ", 9);
write (socketNO, argv[4], strlen(argv[4]));
write (socketNO, "\n", 1);
write (socketNO, "\n", 1);
write (socketNO, argv[5], strlen(argv[5]));
write (socketNO, "\n", 1);
write (socketNO, ".", 1);
write (socketNO, "\n", 1);
/* Quits the connection */
write (socketNO, "QUIT", 4);
int response = read (socketNO, fromServer, 512);
close(socketNO);
cout << response << " " << fromServer << endl;
這裏是我的輸出
~$ client smtp.xxx.xxx [email protected] [email protected] hi hello
hostname is smtp.xxx.xxx
hello
311 220 smtp.xxx.xxx ESMTP Sendmail 8.54.4/8.14.4; Fri, 13 Nov 2015 10:46:23 -0500
250 smtp.xxx.xxx Hello unix.xxx.xxx [128.16.3.12], pleased to meet you
250 2.1.0 <[email protected]>... Sender ok
250 2.1.5 <[email protected]>... Recipient ok
354 Enter mail, end with "." on a line by itself
應該如何看待
~$ client smtp.xxx.xxx [email protected] [email protected] hi hello
hostname is smtp.xxx.xxx
hello
311 220 smtp.xxx.xxx ESMTP Sendmail 8.54.4/8.14.4; Fri, 13 Nov 2015 10:46:23 -0500
HELO smtp.xxx.xxx
250 smtp.xxx.xxx Hello unix.xxx.xxx [128.16.3.12], pleased to meet you
MAIL FROM:<[email protected]>
250 2.1.0 <[email protected]>... Sender ok
RCPT TO:<[email protected]>
250 2.1.5 <[email protected]>... Recipient ok
DATA
354 Enter mail, end with "." on a line by itself
SUBJECT: hi
hello
.
QUIT
好的,但問題是什麼? – vladon
如何閱讀正在寫入服務器的命令..我通過編輯進行了更多澄清......對於模糊性的道歉 – brunzzy