如何使用javascript或jquery发送电子邮件 [英] How to send email by using javascript or jquery
问题描述
我为博客开发了一个网络表单,我需要将其值发送到电子邮件。
I developed a web-form for a blog, and I need to send its values to an email.
如何使用jQuery或JavaScript发送电子邮件单独?
How can I send an email by using jQuery or JavaScript alone?
推荐答案
简短的回答是你无法单独使用JavaScript。您需要一个服务器端处理程序来连接SMTP服务器以实际发送邮件。网上有很多简单的邮件脚本,例如PHP的这个:
The short answer is that you can't do it using JavaScript alone. You'd need a server-side handler to connect with the SMTP server to actually send the mail. There are many simple mail scripts online, such as this one for PHP:
使用这样的脚本,您可以将Web表单的内容发布到脚本中,使用这样的函数:
Using a script like that, you'd POST the contents of your web form to the script, using a function like this:
然后脚本将获取这些值,加上邮件服务器的用户名和密码,并连接到服务器以发送邮件。
And then the script would take those values, plus a username and password for the mail server, and connect to the server to send the mail.
这篇关于如何使用javascript或jquery发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!