Alexis
Alexis

Reputation: 25223

Using Javascript to connect with server using protocol other than HTTP

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.

Upvotes: 3

Views: 2477

Answers (2)

Alexander Sagen
Alexander Sagen

Reputation: 4038

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.

Upvotes: 1

Tomalak
Tomalak

Reputation: 338326

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.

Upvotes: 1

Related Questions