I've got a feedback HTML form, the results of which I need to send to an e-mail address. How do I do that in JavaScript?
我有一个反馈HTML表单,我需要将结果发送到一个电子邮件地址。如何用JavaScript实现呢?
11 个解决方案
#1
2
You can't. You will need to use some sort of background technology, such as python, ruby, coldfusion, php or ASP in order to send it to your email.
你不能。您需要使用一些背景技术,比如python、ruby、coldfusion、php或ASP,以便将其发送到您的电子邮件中。
There's a few free services on the nets that will allow you to do that using their own resources, but if you are dealing with secure information, you better use your own resources.
网上有一些免费的服务可以让你使用他们自己的资源,但是如果你处理的是安全信息,你最好使用你自己的资源。
Here's a free PHP service that will allow you to do something like that, but just remember that this kind of service is normally unreliable.
这里有一个免费的PHP服务,可以让您做类似的事情,但是请记住,这种服务通常是不可靠的。
#2
1
Your only option is to submit it is a regular form and then send on server side.
您唯一的选择是提交它是一个常规的表单,然后发送到服务器端。
#3
1
One way you can attempt to do this is have a
一种方法是
<form action="mailto:example@example.com">
when submitting this will attempt to email the form to the given email address, this is a pretty nasty solution as it relies on the client having a correctly configured mail client. Also you have no controll over the presentation of the email. see Beware of Form Mailto Action for some of the pitfalls.
当提交时,将尝试将表单发送到给定的电子邮件地址,这是一个非常糟糕的解决方案,因为它依赖于客户机拥有正确配置的邮件客户机。此外,你对电子邮件的呈现也没有控制权。请注意表单Mailto操作的一些缺陷。
#4
0
Impossible, for only with javascript, but with the help of server side script, you could.
不可能,因为只有使用javascript,但是在服务器端脚本的帮助下,您可以这样做。
Please take a look php mail function here
请在这里查看php邮件函数
#5
0
Other than possibly AJAX I know of no other way.
除了阿贾克斯,我不知道还有别的办法。
EDIT: To clarify - AJAX would call another function like PHP to actually send the mail. You'd need to implement it serverside.
编辑:澄清——AJAX会调用另一个函数,比如PHP来发送邮件。您需要在服务器端实现它。
EDIT2: Here's an article
EDIT2:这是一篇文章中写道
#6
0
You have two options:
你有两个选择:
1) Use a mailto link. Javascript isnt really necessary although you could use Javascript to "click" the mailto link. This will cause the user's email client to open with a new email prepopulated with the recipient's email address. mailto links There are numerous reasons why mailto links are unreliable (see comments below). They are not recommended.
1)使用mailto链接。虽然可以使用Javascript“单击”mailto链接,但是Javascript并不是必需的。这将导致用户的电子邮件客户端打开一个新的电子邮件预先填充收件人的电子邮件地址。mailto链接有很多不可靠的原因(见下面的评论)。他们不推荐。
2) Submit a form back to the server then send the email from the server. Whatever the server side code is (php, c# etc) should have the ability to send email. This way you can guarantee the email was sent.
2)向服务器提交表单,然后从服务器发送邮件。无论服务器端代码是什么(php、c#等)都应该能够发送电子邮件。这样你就可以保证邮件发送了。
You cannot silently send email from the browser. It has to either happen with user assistance or on the server.
你不能默默地从浏览器发送电子邮件。它必须在用户帮助或服务器上发生。
#7
0
its impossible :) but, you can use jQuery and backend application, written by python(django), php, asp.net, etc.
但是,您可以使用jQuery和后端应用程序,由python(django)、php、asp.net等编写。
Simple jQuery script:
简单的jQuery脚本:
$('#button').click(function(){
$.post('backend.php',
{message:$('#message').val(),
name: $('#name').val(),
email:$('#email').val()},
function(data) {
$('.result').html(data);
});
});
And PHP script:
和PHP脚本:
<?php
if($_POST['message'])
{
$body = "Name: ".$_POST['name'];
$body .= "<br>Email: ".$_POST['email'];
$body .= "<br>Message: ".$_POST['message']
if(mail("yourmail@mail.com","Subjects",$body))
echo 'true';
else echo 'false;';
}
?>
its simple, without security fix.
它很简单,没有安全修复。
#8
0
You can not do that with pure javascript, you might want to use ajax for that too but yet behind the scenes there should be a server-side language to send the email.
纯javascript无法做到这一点,您可能也想使用ajax实现这一点,但在后台应该有一个服务器端语言来发送电子邮件。
#9
0
If you want something that even comes close to working for a reasonable number of people then, keeping within the constraints of the question, you need to use server side JavaScript (the specifics depend on the particular implementation of SSJS you are using, see Whitebeam for an example).
如果您想要一些甚至接近于为合理数量的人工作的东西,那么在问题的约束下,您需要使用服务器端JavaScript(具体情况取决于您正在使用的SSJS的具体实现,请参见Whitebeam)。
#10
-1
you have to use server side scripting like php or perl
您必须使用服务器端脚本,如php或perl
send the form content to the server side php. write using sendmail function in php.
将表单内容发送到服务器端php。使用php中的sendmail函数编写。
your content will be sent to that email.
您的内容将被发送到该电子邮件。
#11
-2
You cannot send mails with client side javascript. Submit the form to a server side script like PHP/JSP/ASP etc and send mail from that script.
不能使用客户端javascript发送邮件。将表单提交给服务器端脚本,如PHP/JSP/ASP等,并从该脚本发送邮件。
#1
2
You can't. You will need to use some sort of background technology, such as python, ruby, coldfusion, php or ASP in order to send it to your email.
你不能。您需要使用一些背景技术,比如python、ruby、coldfusion、php或ASP,以便将其发送到您的电子邮件中。
There's a few free services on the nets that will allow you to do that using their own resources, but if you are dealing with secure information, you better use your own resources.
网上有一些免费的服务可以让你使用他们自己的资源,但是如果你处理的是安全信息,你最好使用你自己的资源。
Here's a free PHP service that will allow you to do something like that, but just remember that this kind of service is normally unreliable.
这里有一个免费的PHP服务,可以让您做类似的事情,但是请记住,这种服务通常是不可靠的。
#2
1
Your only option is to submit it is a regular form and then send on server side.
您唯一的选择是提交它是一个常规的表单,然后发送到服务器端。
#3
1
One way you can attempt to do this is have a
一种方法是
<form action="mailto:example@example.com">
when submitting this will attempt to email the form to the given email address, this is a pretty nasty solution as it relies on the client having a correctly configured mail client. Also you have no controll over the presentation of the email. see Beware of Form Mailto Action for some of the pitfalls.
当提交时,将尝试将表单发送到给定的电子邮件地址,这是一个非常糟糕的解决方案,因为它依赖于客户机拥有正确配置的邮件客户机。此外,你对电子邮件的呈现也没有控制权。请注意表单Mailto操作的一些缺陷。
#4
0
Impossible, for only with javascript, but with the help of server side script, you could.
不可能,因为只有使用javascript,但是在服务器端脚本的帮助下,您可以这样做。
Please take a look php mail function here
请在这里查看php邮件函数
#5
0
Other than possibly AJAX I know of no other way.
除了阿贾克斯,我不知道还有别的办法。
EDIT: To clarify - AJAX would call another function like PHP to actually send the mail. You'd need to implement it serverside.
编辑:澄清——AJAX会调用另一个函数,比如PHP来发送邮件。您需要在服务器端实现它。
EDIT2: Here's an article
EDIT2:这是一篇文章中写道
#6
0
You have two options:
你有两个选择:
1) Use a mailto link. Javascript isnt really necessary although you could use Javascript to "click" the mailto link. This will cause the user's email client to open with a new email prepopulated with the recipient's email address. mailto links There are numerous reasons why mailto links are unreliable (see comments below). They are not recommended.
1)使用mailto链接。虽然可以使用Javascript“单击”mailto链接,但是Javascript并不是必需的。这将导致用户的电子邮件客户端打开一个新的电子邮件预先填充收件人的电子邮件地址。mailto链接有很多不可靠的原因(见下面的评论)。他们不推荐。
2) Submit a form back to the server then send the email from the server. Whatever the server side code is (php, c# etc) should have the ability to send email. This way you can guarantee the email was sent.
2)向服务器提交表单,然后从服务器发送邮件。无论服务器端代码是什么(php、c#等)都应该能够发送电子邮件。这样你就可以保证邮件发送了。
You cannot silently send email from the browser. It has to either happen with user assistance or on the server.
你不能默默地从浏览器发送电子邮件。它必须在用户帮助或服务器上发生。
#7
0
its impossible :) but, you can use jQuery and backend application, written by python(django), php, asp.net, etc.
但是,您可以使用jQuery和后端应用程序,由python(django)、php、asp.net等编写。
Simple jQuery script:
简单的jQuery脚本:
$('#button').click(function(){
$.post('backend.php',
{message:$('#message').val(),
name: $('#name').val(),
email:$('#email').val()},
function(data) {
$('.result').html(data);
});
});
And PHP script:
和PHP脚本:
<?php
if($_POST['message'])
{
$body = "Name: ".$_POST['name'];
$body .= "<br>Email: ".$_POST['email'];
$body .= "<br>Message: ".$_POST['message']
if(mail("yourmail@mail.com","Subjects",$body))
echo 'true';
else echo 'false;';
}
?>
its simple, without security fix.
它很简单,没有安全修复。
#8
0
You can not do that with pure javascript, you might want to use ajax for that too but yet behind the scenes there should be a server-side language to send the email.
纯javascript无法做到这一点,您可能也想使用ajax实现这一点,但在后台应该有一个服务器端语言来发送电子邮件。
#9
0
If you want something that even comes close to working for a reasonable number of people then, keeping within the constraints of the question, you need to use server side JavaScript (the specifics depend on the particular implementation of SSJS you are using, see Whitebeam for an example).
如果您想要一些甚至接近于为合理数量的人工作的东西,那么在问题的约束下,您需要使用服务器端JavaScript(具体情况取决于您正在使用的SSJS的具体实现,请参见Whitebeam)。
#10
-1
you have to use server side scripting like php or perl
您必须使用服务器端脚本,如php或perl
send the form content to the server side php. write using sendmail function in php.
将表单内容发送到服务器端php。使用php中的sendmail函数编写。
your content will be sent to that email.
您的内容将被发送到该电子邮件。
#11
-2
You cannot send mails with client side javascript. Submit the form to a server side script like PHP/JSP/ASP etc and send mail from that script.
不能使用客户端javascript发送邮件。将表单提交给服务器端脚本,如PHP/JSP/ASP等,并从该脚本发送邮件。