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