on writing a POP3 client in C
I am working on a simple pop3 client in C and I encountered the following issue: In AUTHORIZATION state, the server will never recognise my password:
Connection successful: +OK GMX POP3 StreamProxy ready user hopatropa@gmx.com +OK May I have your password, please? pass ****** -ERR Username or password incorrect
but the same succession of commands works nicely in telnet
+OK GMX POP3 StreamProxy ready user hopatropa@gmx.com +OK May I have your password, please? pass ****** +OK Mailbox locked and ready
I am sure that the password I send is alright. This is how I send the pass command and receive the answer:
sprintf (command, "pass %s\r\n", pass); //pass is the string containing the password printf("%s", command); if (write(sock, command, sizeof(command)) == -1) { fprintf(stderr, "write() error: %d\n", errno); return errno; } if (read(sock, msgbuff, sizeof(msgbuff)) == -1) { fprintf(stderr, "read() error: %d\n",开发者_开发知识库 errno); return errno; }
Any help would be greatly appreciated.
Why are you using sizeof(command) and not strlen(command) for the length?
精彩评论