如何在没有服务器的情况下发送电子邮件?只有带有 sendgrid 的前端 Javascript 或
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32041229/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can i send emails without a server ? Only front-end Javascript with sendgrid or
提问by darkylmnx
i was wondering lately how i could send emails with only a front-end language like Javascript through Email as a Service apps like sendgrid or mandrill or so.
我最近想知道如何通过电子邮件即服务应用程序(如 sendgrid 或 mandrill 等)仅使用前端语言(如 Javascript)发送电子邮件。
Sendgrid and mandrill have Curl APIS, so basically i can just do an AJAX post request to their API to send a mail but the thing is, i will have to put my API secret key in the JS file, this means it will be public... while it's supposed to be secret.
Sendgrid 和 mandrill 有 Curl APIS,所以基本上我可以对他们的 API 执行 AJAX 发布请求来发送邮件,但问题是,我必须将我的 API 密钥放在 JS 文件中,这意味着它将是公开的。 ..虽然它应该是秘密的。
On those two apps, there's nothing in the docs concerning front-end use except having your own server which will use the API, but i'm currently on front-end based project. No server programming, the server only renders the assets that's all.
在这两个应用程序上,除了拥有自己的将使用 API 的服务器之外,文档中没有任何关于前端使用的内容,但我目前在基于前端的项目中。没有服务器编程,服务器只渲染资产。
Do you guys know any method or apps of this kind to acheive this ? Thanks
你们知道任何方法或应用程序来实现这一目标吗?谢谢
回答by Avik
You can use FormSpree. Just provide the url in form action.
您可以使用 FormSpree。只需在表单操作中提供 url。
回答by Mousey
Several suugestions
几个建议
- dropbox formsvia jotbox includes encryption and a paid SSL option
- sendgrid using parse cloud instructions
- third party service, eg 123contactform
- use a not-so-secure php form with extra javascript to mask the email address, see responses on this threadincluding Dave Jarvis' php code
- 通过 jotbox 的Dropbox 表单包括加密和付费 SSL 选项
- sendgrid 使用解析云指令
- 第三方服务,例如123contactform
- 使用不那么安全的 php 表单和额外的 javascript 来屏蔽电子邮件地址,请参阅此线程上的回复,包括 Dave Jarvis 的 php 代码
回答by Jonathan Pool
An alternative is to let each user use his or her own outgoing mail server, by using a mailto: link, which allows you to specify the header information and also a quasi-header named “body”, which puts the content you want into the message body.
另一种方法是让每个用户使用他或她自己的外发邮件服务器,通过使用 mailto: 链接,它允许您指定标题信息和一个名为“body”的准标题,它将您想要的内容放入邮件正文。
回答by M3RS
You could use a serverless architecture with AWS Lambda functions written in JavaScript.
您可以将无服务器架构与用 JavaScript 编写的 AWS Lambda 函数结合使用。
回答by Ivan
If you'd like to keep the key secure you can use something like Aerobatic's HTTP Proxyto specify the key and proxy through the server environment.
如果您想保证密钥的安全,您可以使用 Aerobatic 的HTTP 代理之类的东西通过服务器环境指定密钥和代理。