I try to create an IMAP client using sockets.
I successfully connect to server and receive welcome message but when trying to login and sending logging information(username and password) server won't response. Here is sample of my code:
b_send = send(client_socket, "a1 LOGIN username password", strlen("a1 LOGIN username password"), 0);
if (b_send < 0)
perror("ERROR in send");
printf("Sent, waiting for response.\n");
b_rcv = recv(client_socket, buf, BUFSIZE, 0);
if (b_rcv < 0)
perror("ERROR in rcv");
printf("Echo from server: %s", buf);
You never sent the required
See https://tools.ietf.org/html/rfc3501 section 2.2.
All interactions transmitted by client and server are in the form of
lines, that is, strings that end with a CRLF.
Also, why would you repeat your string like that? Put it in a variable.