客户端javascript做不到发邮件功能,你只能用服务器端的代码来做
做不到,js只能不自定义请求协议头文件,发送出去邮件服务器不鸟你
单单js不能做不到,需要api支持的。jmail也算是其中api,当然还可以用其它的api,理解就是服务器必须支持最少其中一种。iis里有现成的cgi,aspmail,php有现成的简单SMTP服务器。
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function mailsome1(){
who=prompt("Enter recipient's email address: ","antispammer@earthling.net");
what=prompt("Enter the subject: ","none");
if (confirm("Are you sure you want to mail "+who+" with the subject of "+what+"?")==true){
parent.location.href='mailto:'+who+'?subject='+what+'';
}
}
// End -->
</SCRIPT>
<a href='javascript:mailsome1()'>E-Mail Someone!</a>
<FORM>
<input type=button value="E-Mail Someone!" onClick="mailsome1()">
</FORM>
需要电脑服务器
npm install http-server -g
纯js 实现不了 ,但可以调起本机Email应用
或者使用nodejs 来实现
需要安装邮件客户端软件
<script language=javascript>
location="mailto:xxx@qq.com?subject=test&cc=xxx@qq.com&subject=主题&body=内容";
</script>