从 Javascript 发送电子邮件
我知道这个主题已经从各个角度被涵盖,但我不确定我是否已经看到了我的具体问题的答案。
我正在用 HTML5、CSS 和 Javascript 编写一个原型网页。我希望用户能够浏览到要附加的文件,然后将该文件附加到我发送到我设置的特定电子邮件地址的电子邮件中。我不希望弹出用户的默认电子邮件程序。
我在公司内部网中有 SMTP 服务器的地址,但目前无法访问服务器来放置服务器端代码。在网页上,用户会知道涉及电子邮件,但我不希望他们除了选择文件并单击按钮而不会弹出其他屏幕之外,还必须执行其他操作。
我知道如何使用 mailto 来发送电子邮件,但我认为您不能将其与附件一起使用。
有没有办法在不干扰服务器端的情况下做到这一点?知道我有权限的 smtp 服务器地址就足够了吗?同样,这是一个原型,但可能是产品新功能的基础。
谢谢!
I know this topic has been covered from all sorts of angles but I'm not sure I've seen the answer to my specific question.
I am writing a prototype web page in HTML5, CSS, and Javascript. I want the user to be able to browse to a file to attach then attach that file to an email I send to a specific email address I've setup. I don't want the user's default email program to pop up.
I have addresses to SMTP servers within my companies intranet but I don't have access to a server at the moment to put server-side code on. On the web page the user will know email is involved but I don't want them to have to do a thing other than select the file and click a button with no other screens popping up.
I know how to use mailto in order to send an email but I don't think you can use that with attachments.
Is there anyway to do this without having to mess with the server side? Is knowing an smtp server address that I have permissions on enough? Again, this is a prototype but possibly the basis for a new feature on a product.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
不,除非目标浏览器公开了 SMTP 客户端对象。 (我认为没有任何作用。这将使垃圾邮件僵尸网络更容易构建......)
您需要在服务器上执行此操作。
Nope, not unless the target browser has exposes an SMTP client object. (And I don't think any do. That would make spam botnets quite a bit easier to build...)
You need to do this on the server.
电子邮件不能仅由客户端发送。如果您希望在客户端使用 mailto 链接,则必须使用 mailto 链接,但这不是最好的方法。相反,您应该向服务器发送请求并进行服务器端处理。如果您有 SMTP 凭据,您可以使用服务器端发送电子邮件。
Email cant be sent just by client side . You must either use a mailto link if you want it on client side but that's not best way . Instead you should send a request to server and do server side processing .If you have SMTP credential you can send email with server side.
我最近为 PostageApp 编写了一个插件,可以让您通过 jQuery 发送电子邮件。基本上,您只需将 API 密钥与消息负载一起提供给它,然后就可以发送它了。使用 PostageApp,您可以将 SMTP 服务器添加到应用程序并通过它们发送。
用法如下:
我没有发布该插件,因为...它对于生产使用没有任何意义,因为您的 API 密钥已公开,这不是一件好事。然而,它对于原型设计来说是不错的(我使用它!),我很乐意分享。
(全面披露:我是 PostageApp 的产品经理。)
I recently wrote a plugin for PostageApp that lets you send emails through jQuery. Basically, you just have to feed it your API key along with the message payload and you can send it through. With PostageApp, you can add your SMTP servers to the app and send through them.
Usage looks like this:
I didn't publish the plugin because well... it never made sense for production usage because your API key was exposed and that's not a good thing. However, it is decent for prototyping (I use it!) and I would be happy to share.
(Full Disclosure: I am the Product Manager of PostageApp.)