views:

51

answers:

3

Hi all,

I am trying to check pop and smtp values entered by user.. I mean i wish to validate that pop and smtp say for example(pop.gmail.com,smtp.gmail.com) which is entered by user is correct or wrong like that..

For that i am sending only one request to server by taking both pop and smtp values entered by user which will do two tasks 1. Checks user entered pop by making connection to that particular server , 2. Checks user entered smtp by sending 1 mail to some dummy mail id.. I finished all these tasks..

But now what my requirement is, i have to show the user after validating each thing.. I mean in ui i have to show as

  1. POP connection Checked.. ok
  2. smtp connection Checked.. ok like that.

But i sent only one request to server for doing both these tasks..So i need to get intermediate status from server after finishing each tasks..So only i can update in client side UI.. But i don't know is it possible to get intermediate responses from server for a single request... Any idea friends? If s can u come up with a little bit of code...

Expecting the suggestions?

A: 

Hello,

you should take a look in the long polling technique, it is possible to retrieve partial response but it doesn't work on all browsers.

RageZ
A: 

You can use HEAD request instead of GET or POST which only return HTTP header

DroidIn.net
A: 

Slightly off topic - but sending a dummy mail can be "dangerous".

Many servers "note" if you try and send to a local address, which does not exist. For example - if the server's domain is "whatever.com" and you send to a random address, say [email protected], and "aaa" is not a valid user, then the server notices this.

The server may then take an action like blocking you, as a sender, for a period of time. (This helps to reduce spam from dictionary attacks.) So your "test" ends up effectively blocking the real mail from being delivered.

The reverse is also true. Let's say you try to send to an external address, which you know is valid (your own email address for example) as the test. In this case the from address must be a valid internal address. If you use an invalid internal address, or worse an address which is not internal, it's likely the server will refuse to deliver the mail (at best) and at worst again institute a temporary block.

The key factor in both these situations is that although the SMTP protocol is very "loose", SMTP servers watch very closely for "bad behavior" because this is one way of distinguishing a spamming program. So any hide of "incorrect" behavior can lead to it arbitrarily refusing to accept your mails (usually for a limited period of time.)

Incidentally, back to your original question. Both of your tests are pretty much instantaneous. Even if the email server is on the other side of the world you can do both checks inside a couple seconds. So chances are even if you send back 2 packets, to the user they'll appear as "arriving together". And since 1 request from the browser can only handle 1 response from the server you would need to send the response in 2 packets.

ie do first test - send first part of response - do second test - send second part of response.

For a normal HTTP packet this is no big deal. Do some sort of flush / send after the first response is ready, and then again after the second response. The browser is used to displaying partial pages as they arrive.

However for an AJAX request you'll need to get into your framework at quite a low level. Most frameworks, that I'm aware of, require the incoming Async packet to be "complete" before they start to parse it. This is especially true if the packet is formatted as say xml where partial parsing is useless in pretty much all cases.

Bruce
Hi Bruce,Sorry, i wont send mail to dummy mail id.. I will send dummy mail to our admin mail id.. Any way i really appreciate your suggesstion..
Senthil
Ya you are correct... They are blocking for a period of time temporarly.. Then how can i check for valid email id and password which entered by the user???
Senthil
Testing the id and password is easy - after all if it doesn't work, then it's wrong. However you may then need to wait a while before you're allowed to test again. There's no real way around that because Email servers _specifically_ don't like being "tested" in any way.So _any_ failure on your side is likely to leave the server isolating you for a bit.And it gets worse, because if you have multiple users then a failure for 1 user will cause all the other legitimate mails from your server (for other user) to fail as well.
Bruce
There's not a lot you can do about this. It's the way servers behave, and for very good reasons. Get the user to enter the details twice - that'll help trap basic spelling errors. After that there's little you can do but queue a test mail to be sent and if it fails alert the user. But this could take a while so it's not something you can do "while they wait."
Bruce