利用javascript发送email
把如下代码加入<body>区域中: <script Language="JavaScript">
<!-- bought to you by A1 Javascripts.com -->
<!-- hide script from non compliant broswers
function mailIt(form) {
var data = document.dataForm
var userInfo = "" // comment out the next line if you want to hardcode the recipient
// then add '[email protected]' to the 'mailform' action attribute
// (i.e. -- ACTION="mailto:[email protected]")
form.action += data.recipient.value // comment out the next line if you want to hardcode the subject
// then add '?subject=example' to the 'mailform' action attribute.
// You must hardcode an address before you can hardcode a subject.
// (i.e. -- ACTION="mailto:[email protected]?subject=example")
form.action += "?subject=" + data.subject.value userInfo += "Page Title: " + document.title + "\n"
userInfo += "Mailed From: " + document.location + "\n\n" form.mailBody.value = userInfo + "\n"+data.name.value +"\n"
+ data.country.value + "\n" + data.email.value
+ "\n"+data.comments.value
return true
}
// end hiding from non compliant browsers-->
<!-- http://www.a1javascripts.com -->
</script> 再把以下代码放入页面合适位置: <!-- --><table>
<form NAME="dataForm">
<!-- DELETE THIS TABLE ROW IF YOU'RE HARDCODING A RECIPIENT -->
<tr>
<th ALIGN="right">Recipient:
<td><input NAME="recipient" SIZE="40" VALUE="[email protected]">
</tr>
<!-- DELETE THIS TABLE ROW IF YOU'RE HARDCODING A SUBJECT -->
<tr>
<th ALIGN="right">Subject:
<td><input NAME="subject" SIZE="40" VALUE="Hello from A1 JavaScripts">
</tr><tr>
<th ALIGN="right" VALIGN="top">Your Name:
<td><input NAME="name" SIZE="40" VALUE>
</tr>
<tr>
<th ALIGN="right" VALIGN="top">Country:
<td><input NAME="country" SIZE="40" VALUE>
</tr>
<tr>
<th ALIGN="right" VALIGN="top">Email:
<td><input NAME="email" SIZE="40" VALUE>
</tr>
<tr>
<th ALIGN="right" VALIGN="top">Comments:
<td><input NAME="comments" SIZE="40" VALUE>
</tr>
</form>
</table>
<form NAME="mailForm" ACTION="mailto:" METHOD="post" ENCTYPE="text/plain" onSubmit="return mailIt(this)">
<input TYPE="hidden" NAME="mailBody" VALUE>
<tr>
<td COLSPAN="2" ALIGN="right">
<input TYPE="submit" VALUE="Send My Email Now">
</tr>
</form>
<!-- -->
把如下代码加入<body>区域中: <script Language="JavaScript">
<!-- bought to you by A1 Javascripts.com -->
<!-- hide script from non compliant broswers
function mailIt(form) {
var data = document.dataForm
var userInfo = "" // comment out the next line if you want to hardcode the recipient
// then add '[email protected]' to the 'mailform' action attribute
// (i.e. -- ACTION="mailto:[email protected]")
form.action += data.recipient.value // comment out the next line if you want to hardcode the subject
// then add '?subject=example' to the 'mailform' action attribute.
// You must hardcode an address before you can hardcode a subject.
// (i.e. -- ACTION="mailto:[email protected]?subject=example")
form.action += "?subject=" + data.subject.value userInfo += "Page Title: " + document.title + "\n"
userInfo += "Mailed From: " + document.location + "\n\n" form.mailBody.value = userInfo + "\n"+data.name.value +"\n"
+ data.country.value + "\n" + data.email.value
+ "\n"+data.comments.value
return true
}
// end hiding from non compliant browsers-->
<!-- http://www.a1javascripts.com -->
</script> 再把以下代码放入页面合适位置: <!-- --><table>
<form NAME="dataForm">
<!-- DELETE THIS TABLE ROW IF YOU'RE HARDCODING A RECIPIENT -->
<tr>
<th ALIGN="right">Recipient:
<td><input NAME="recipient" SIZE="40" VALUE="[email protected]">
</tr>
<!-- DELETE THIS TABLE ROW IF YOU'RE HARDCODING A SUBJECT -->
<tr>
<th ALIGN="right">Subject:
<td><input NAME="subject" SIZE="40" VALUE="Hello from A1 JavaScripts">
</tr><tr>
<th ALIGN="right" VALIGN="top">Your Name:
<td><input NAME="name" SIZE="40" VALUE>
</tr>
<tr>
<th ALIGN="right" VALIGN="top">Country:
<td><input NAME="country" SIZE="40" VALUE>
</tr>
<tr>
<th ALIGN="right" VALIGN="top">Email:
<td><input NAME="email" SIZE="40" VALUE>
</tr>
<tr>
<th ALIGN="right" VALIGN="top">Comments:
<td><input NAME="comments" SIZE="40" VALUE>
</tr>
</form>
</table>
<form NAME="mailForm" ACTION="mailto:" METHOD="post" ENCTYPE="text/plain" onSubmit="return mailIt(this)">
<input TYPE="hidden" NAME="mailBody" VALUE>
<tr>
<td COLSPAN="2" ALIGN="right">
<input TYPE="submit" VALUE="Send My Email Now">
</tr>
</form>
<!-- -->
通过smtp来发送邮件,实现中..........嘿嘿~~
其实也可以
用js写asp ^^不过等于自己骗自己……
<a href="mailto:[email protected]">发送邮件给我</a>
呵呵!