Is it possible to build a SMTP/IMAP client that can run in the browser that uses only Javascript?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
It's currently not possible to do in a normal web app in the browser. It is however possible to do in packaged apps with access to privileged apis:
- Firefox Apps use the emerging W3C standard (TCPSocket): https://developer.mozilla.org/en-US/docs/Web/API/TCPSocket
- Chrome Apps use a proprietary api (chrome.socket): https://developer.chrome.com/apps/socket
If you're looking for a battle proven library, whiteout.io develops and maintains a well tested IMAP / SMTP / MIME-codec implementation in pure JS:
http://emailjs.org
It's MIT licensed and free to use.
回答2:
Agree with Daniel, its not possible in javascript.
There is a new WebSockets API that's going to be added to browsers to allow communication over sockets, but even after that is introduced it will NOT be possible. WebSockets API goes to great lengths to ensure such a thing is not possible, because it is a security risk.