从 Javascript 发送邮件
我正在做我的第一个 Chrome 扩展,但在发送邮件(没有表单)时遇到了一些问题,因为我无法仅使用 html+javascript 来完成此操作,并且 Chrome 不提供任何工具来完成此操作。
我正在考虑在我的服务器中做一个服务,通过 POST 调用获取邮件的所有字段作为参数,然后使用 PHP 发送邮件,但我有点担心安全性(每个人都可以调用我的服务)。
我的服务器如何区分来自 Chrome 扩展程序的消息和来自其他来源的消息?
对不起我的英语, 谢谢!
I', doing my first Chrome extension and i'm having some problems sending mails (without form) cause i cant't do it only with html+javascript and Chrome dont provide any tool to do it.
I'm thinking to do a service in my server that gets all the field of the mail as parameter with a POST call and then send mail with PHP, but i'm a bit worried about the security (everybody can call my service).
How can my server distinguish between messages coming from my Chrome extension and messages from other sources?
Sorry my english,
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您应该实施一些授权机制。查看 Oauth。
PS1:使用Oauth2(点击oauth网站底部的链接)。
PS2:我在这里也找到了一个很好的指南: http: //hueniverse.com/2007/10/beginners-guide-to-oauth-part-i-overview/
You should implement some authorization mechanism. Check out Oauth.
PS1: Use Oauth2 (follow the link at the bottom of the oauth website).
PS2: I found a nice guide also here: http://hueniverse.com/2007/10/beginners-guide-to-oauth-part-i-overview/
事实上,您在客户端所能做的就是打开一个邮件程序并让用户自己发送。 (这可能也是一件好事。)
如果您免费分发 Chrome 扩展程序,则任何获得副本的人都可以重现您在扩展程序中实现的任何授权机制。您可以应用各种混淆技术来尝试使这一点不那么明显,但最终您已经交出了密钥,因此您无法阻止任何人访问您的服务。
在这种情况下,仅包含令牌保护,例如
source=myextension
参数,只是为了阻止服务在偶然发现地址时被自动蜘蛛攻击。然后集中精力确保表单邮件服务本身是安全的,并且只允许将特定的邮件正文发送到预定义的地址,因此它不会被滥用于垃圾邮件。如果您限制扩展程序的分发,以便每个人都可以拥有自己的访问密钥,那么您可以做得更多。
Indeed, all you can do on the client side is open a mailer and let the user send themselves. (That's probably a good thing, too.)
If you're freely distributing a Chrome extension, anyone who gets a copy can reproduce any authorisation mechanism you implement in the extension. You can apply various obfuscation techniques to try to make this less obvious, but in the end you have already handed over the keys so there's nothing you can do to stop anyone accessing your service.
In that case, include only a token protection, such as a
source=myextension
parameter, just to stop the service getting hit by automated spiders if the stumble across the address. Then concentrate on making sure the form-mail service itself is secure and only allows specific mail bodies to be sent to predefined addresses, so it can't be abused for spam.If you have restricted distribution of the extension so that everyone can have their own access key, you could do more.
我已经有一段时间没有这样做了,但您也可以将表单序列化为 mailto: 链接,然后触发该链接。然后,该电子邮件将在用户的默认邮件客户端中弹出。
It's been awhile since I did this but you can also serialize the form into a mailto: link and then trigger that link. The email will then popup in the user's default mail client.