从Chrome扩展程序发送电子邮件 [英] Sending email from Chrome extension

查看:380
本文介绍了从Chrome扩展程序发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不希望用户必须执行或确认任何操作,因为这会破坏总体思路。换句话说,mailto是不可能的。



是否可以通过Chrome浏览器扩展程序通过JavaScript发送客户端电子邮件,而不会中断用户体验或添加任何JavaScript扩展?如果是这样怎么样?



我觉得这是不可能的。

编辑:我已经了解到,有一个chrome.sockets.tcp API可用,任何想法如何?



为什么所有的downvotes?这不像我试图提出一个问题,你都必须讨厌,我只是想要这个信息,所以我可以用它来扩展...



解决方案:非常非常辛苦,不值得麻烦(见最佳答案)

解决方案

因为我想不出一个紧密的原因对于这个问题,这里是一个答案。



要发送电子邮件,程序需要通过TCP连接到SMTP服务器并与其通话根据 SMTP协议


  1. 无法直接使用JavaScript / HTML5 API发送电子邮件。



    浏览器不会将直接与TCP套接字进行通信。



    尽管您可以初始化与任何端口的连接,但浏览器会说话而不会说出SMTP 。它可以做HTTP,它可以做WebSocket,但不是你想要的协议。

  2. 不能直接从Chrome浏览器发送电子邮件>扩展程序。



    虽然 Chrome扩展API 增强了Web API提供的功能,但它们仍不能为您提供与服务器进行交谈的机会。 直接从Chrome 应用发送电子邮件是可能的,但并非易事。

    b
    Chrome Apps API 与扩展名不同,但更重要的是,它们包括通过 chrome.sockets.tcp API

    请注意原始访问。你将不得不从JavaScript开始实现你自己的邮件客户端。 这可能是一个起点。



    根据您想要实现的目标,Chrome应用程序可以成为可接受的解决方案。或者,如果您需要扩展程序和应用程序API,则可以在它们之间创建并传递消息。

  3. 原生消息主机本地应用程序,您可以从本地主机应用程序执行任何操作。然后,Chrome扩展程序/应用程序就可以使用必要的数据调用它。然而,如果您决定发布扩展程序,这将限制您的部署选项;您将不得不担心可移植性,并且本地主机无法上传到Web商店;您需要一个单独的安装程序。



    您的邮件主机仍然需要实现您自己的SMTP客户端,尽管您有更多的可用库供您选择。 如需额外阅读,请阅读 Apps vs Extensions 指南。



    请注意:任何后续问题可能都在外面您的原始问题的范围。


    I do not want the user to have to perform or confirm any actions, as it would disrupt the general idea. In other words, mailto is out of the question.

    Is it possible to send emails client-sided via JavaScript, from a Chrome extension, without disrupting the user’s experience or adding any JavaScript extension? If so how?

    I get the feeling this is going to be impossible.

    EDIT: I've learnt that there is a chrome.sockets.tcp API that may be useable, any idea how?

    Why all the downvotes? It's not like I tried to ask a question you all must have hated, I just kinda wanted this information so I could use it in an extension...

    Solution: very very hard, not worth the trouble (see best answer)

    解决方案

    Since I can't think of a close reason for this question, here's an answer..

    To send an e-mail, a program needs to connect via TCP to an SMTP server and talk to it according to the SMTP protocol.

    1. It is not possible to send an e-mail directly using JavaScript / HTML5 APIs.

      A browser does not expose the capability to directly communicate with a TCP socket.

      While you can initiate a connection to any port in principle, the browser will "do the talking" and it does not "speak" SMTP. It can do HTTP, it can do WebSockets, but not the protocol you want.

    2. It's not possible to send an e-mail directly from a Chrome extension.

      While the Chrome extension APIs augment functionality offered by web APIs, they still don't offer you the chance to "do the talking" to a server.

    3. It is possible, but not easy, to send an e-mail directly from a Chrome app.

      Chrome Apps APIs are different from extensions, but more importantly they include raw access to TCP sockets, via chrome.sockets.tcp API.

      Note the words "raw access". You will have to implement your own mail client from scratch in JavaScript. This might be a starting point.

      Depending on what you want to achieve, a Chrome app can be an acceptable solution. Alternatively, if you need both extension and app APIs, you can create both and pass messages between them.

    4. Anything is possible with a Native Messaging host.

      Being basically a native application, you can do anything from a native host app. Chrome extension/app will then be able to call it with necessary data.

      However, this will limit your deployment options if you decide to publish the extension; you will have to worry about portability, and the native host cannot be uploaded to the Web Store; you would need a separate installer.

      And your messaging host will still need to implement your own SMTP client, though you have a much more broad choice of ready libraries for that.

    For extra reading, here's Apps vs Extensions guide.

    Please note that any follow-up questions would probably be outside the scope of your original question.

    这篇关于从Chrome扩展程序发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆