简体   繁体   English

如何使用 JavaScript 将 HTML 表单数据通过电子邮件发送到电子邮件 ID,而不使用服务器端语言,而不使用电子邮件客户端安全?

[英]How to send HTML form data by email to an email ID by using JavaScript, without using server-side language, without using email client securely?

How to send HTML form data by email to an email ID by using JavaScript and without using server-side language and without using email client securely?如何通过电子邮件将 HTML 表单数据发送到电子邮件 ID,使用 JavaScript,不使用服务器端语言,也不安全地使用电子邮件客户端? I do not want any email client to pop open on clicking submit.我不希望任何电子邮件客户端在单击提交时弹出。

It's very simple to send email by JavaScript:通过 JavaScript 发送电子邮件非常简单:

 <textarea id="Body">
     Mail Content
 </textarea>
 <button onclick="sendMail();">Send</button>

SendMail function:发送邮件功能:

function sendMail() {
         var link = "mailto:me@example.com"
         + "?cc=myCCaddress@example.com"
         + "&subject=" + escape("This is my subject")
         + "&body=" + escape(document.getElementById('Body').value)
     ;

     window.location.href = link;
 }

You can call SendMail() function on submit.您可以在提交时调用SendMail()函数。 Hope this help you.希望这对您有所帮助。

Your requirement basically says that you want to hit an smtp server directly and the mail should go from there.您的要求基本上是说您想直接访问 smtp 服务器,并且邮件应该从那里发送。

This would mean that Javascript should support a way to send data to an smtp server.这意味着 Javascript 应该支持一种将数据发送到 smtp 服务器的方式。

The default way to talk to a smtp server is via TCP/IP (you can use telnet on a smtp server, usually on port 25).与 smtp 服务器通信的默认方式是通过 TCP/IP(您可以在 smtp 服务器上使用 telnet,通常在端口 25 上)。

Since Javascript does not support TCP/IP directly it is not possible to do it directly from Javascript.由于 Javascript 不直接支持 TCP/IP,因此无法直接从 Javascript 进行。

This does not mean that这并不意味着

  1. You cannot use a email service which provides rest interface您不能使用提供休息界面的电子邮件服务
  2. Write your own backend based on REST to relay it to an SMTP server基于 REST 编写您自己的后端以将其中继到 SMTP 服务器
  3. Have a backend which acts as a proxy to you incoming rest and translate it to a tcp/ip request and send it to the corresponding server and port有一个后端充当您传入的 rest 的代理,并将其转换为 tcp/ip 请求并将其发送到相应的服务器和端口

The above three methods seem to be the only ways I can think of to send a mail from Javascript.以上三种方法似乎是我能想到的从 Javascript 发送邮件的唯一方法。

Edit: There seems to be a TCPSocket https://developer.mozilla.org/en-US/docs/Web/API/TCPSocket but it is not widely supported.编辑:似乎有一个 TCPSocket https://developer.mozilla.org/en-US/docs/Web/API/TCPSocket但它没有得到广泛支持。

You might also want to look into flash, I don't know how long it will be widely supported though.您可能还想研究 flash,但我不知道它会被广泛支持多久。

It's very much deliberate that you aren't allowed to do this.不允许你这样做是非常刻意的。 If you could, everyone's browsers would be turned into infernal spam-spewing abuse machines.如果可以的话,每个人的浏览器都会变成地狱般的垃圾邮件滥用机器。

From a web page, you can only choose between client-side mail, letting the user confirm what they're sending (and losing some proportion of respondants who aren't in a position to send mail), or a web-accessible server-side mail forwarder (either a third-party service or your own server in which case you have to work out the security yourself).从网页中,您只能在客户端邮件之间进行选择,让用户确认他们正在发送的内容(并失去一部分无法发送邮件的受访者),或者可以访问网络的服务器 -侧邮件转发器(第三方服务或您自己的服务器,在这种情况下,您必须自己解决安全问题)。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在不使用服务器端语言的情况下从 HTML 表单存储/发送数据? - How do I store/send data from a HTML form without using a server side language? 是否可以仅使用Javascript发送电子邮件而不必单击电子邮件客户端上的“发送”按钮? - Can I Send an Email using ONLY Javascript Without Having to Click The Send Button on the Email Client? 如何使用jquery / javascript &amp;&amp;重置html中的表单数据,以及如何使用jquery将表单数据发送到电子邮件? - How to reset the form data in html using jquery/javascript && and also how to send the form data to an email using jquery? 在没有任何服务器端语言的情况下在Javascript中使用MVC? - Using MVC in Javascript without any server-side language? 如何在不使用程序的情况下通过javascript发送电子邮件? - How to send email through javascript without using a program? 使用JavaScript发送电子邮件时进行服务器端验证? - Server side validation when using JavaScript to send an email? 如何使用Javascript发送电子邮件? - How to send Email using Javascript? 使用纯Javascript和NO服务器端技术将表单值从一页安全地发布到客户端的另一页 - Posting form values securely from one page to another on client-side using pure Javascript and NO server-side technology 如何使用客户端 gmail API 发送电子邮件,其中包含 html 内容和图像作为附件 - How to send an email using client side gmail API which have html content and an image as attachment 在 Javascript 函数中发送 AJAX email 而不使用 Z2FEC392304A5C23AC138DA22847BCZ - Send an AJAX email in a Javascript funciton without using PHP
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM