curl-library
RE: SMTP: multi interface produce wrong error code for unknown recipient
Date: Mon, 21 May 2012 22:33:40 +0100
Hi Gokhan,
> I just noticed a small flaw in SMTP when it is used with multi interface.
> If the recipient is unknown by the SMTP server, libcurl ends up with error
> code CURLE_RECV_ERROR instead of a more meaningful one like
> CURLE_LOGIN_DENIED (which is provided with easy interface currently).
> I am not saying CURLE_LOGIN_DENIED is the best error here but it is the
> closest to imply the error. I am doing my tests with the git master branch.
I would expect to see CURLE_LOGIN_DENIED.
> Can you see the problem at a glance? If not, I am going to dig this tomorrow.
I've just looked at the code and all looks okay, however here are some thoughts:
Looking at the log files that you sent, something is incrementing the state from STOP to POSTDATA - that shouldn't happen, as far as I know, and doesn't in the case of the easy interface example you sent through. The only code that advances the state machine to POSTDATA is in smtp_done().
Not only that but as you can see in smtp_state_rcpt_resp() the result gets set to CURLE_LOGIN_DENIED and in smtp_state_postdata_resp() to CURLE_RECV_ERROR which is also the same as you are seeing.
I reckon that if you were to do the following afterwards:
long response;
curl_easy_getinfo(curl, CURLINFO_HTTP_CODE, &response)
I'm pretty sure you would see 500 in "response" and not 550 as also indicated by the log file.
Can anyone who is more familiar with the multi interface tell us if smtp_done() is intentionally called even when there is a failure? It would appear that this function is getting called, which is then sending the EOB sequence and the server is replying with a 500 error as this is not expected at this time - the EOB should only be sent once data is sent..
Additionally, I did see a bizarre bit of code whilst looking at this in smtp_connect() where the pingpong structure seems to be initialised twice - IMHO opinion this doesn't seem right but I don’t think that is to blame!!
Kind Regards
Steve
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2012-05-21