views:

37

answers:

2

Can Javascript be used to connect with a server with a protocol other than HTTP or FILE? Ideally, I would like to connect to an SMTP server using Javascript.

+1  A: 

You do not have socket access with browser-integrated JavaScript, it would violate the sandbox security model. So no, no SMTP, or any other protocol. Even file:// should be rather difficult.

Server based JavaScript like node.js can do things like this.

Accessing e.g. SMTP via the browser is usually done through a proxy script that runs on the server and speaks HTTP to the client.

Tomalak
+1  A: 

Not possible due to security constraints in the browser. Can be done in flash or java as far as I know. The upcoming WebSockets won't help you either.

Your best option is probably to call a script on your server which makes the socket connections to the final destination, i.e the SMTP server and then passes data back to the client over HTTP.

Alexander Sagen