tags:

views:

87

answers:

1

Hi,

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 [email protected]
+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 [email protected]
+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.

+2  A: 

Why are you using sizeof(command) and not strlen(command) for the length?

taspeotis
wow, i didn't expect that to work...I was thinking that the server would stop reading after /r/n...how stupid of me...thanks...it's been eating me for hours. I wouldn't have posted otherwise.
John: For future problems you might want to take a look at wireshark.It's always useful to see what's actually getting sent over the network. In this case the problem would have been fairly easy to see in the network capture.
Kristof Provost