一. 表单mail.htm,首先要保证服务器空间那方装有JMAIL组件,并提供该业务<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><title>mail</title><meta http-equiv="Content-Type" content="text/html; charset=gb2312"></head><body bgcolor="#ddfcdc"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr><td bgcolor="#ddfcdc"><form method="post" action="sendmail.asp"> 请填写以下资料并按寄出键即可 <br> <br> 姓 名: <input type="text" size="20" name="name"><font color="#FF0000">*</font><br><br>电子邮件: <input type="text" size="20" name="email"><font color="#FF0000">*</font><br><br> 联系方式: <input type="text" size="40" name="other"><br><br> 主 题: <input type="text" size="40" name="subject"><br><br> 正 文 <br> <textarea name="body" cols="50" rows="12" wrap="PHYSICAL"></textarea><font color="#FF0000">*</font><br><input type="submit" value="寄出"></form></td> </tr></table></body></html>
(二)通过JMAIL发送E-mail程序:sendmail.asp<%@LANGUAGE = VBSCRIPT%> <html><body><%recipient = "info@123.com" '此为收信人电子邮箱 ' 取得表单资料name = Request.Form("name")senderEmail = Request.Form("email")other=request.Form("other")subject = "Re:" & Request.Form("subject")body = Request.Form("body")if name <> "" and senderEmail <> "" and body<>"" then' 建立 JMail 组件set msg = Server.CreateOBject( "JMail.Message" )' 设定将寄信的过程记录下来msg.Logging = truemsg.silent = true' 中文编码设定msg.Charset = "gb2312"' 将表单资料存入组件中msg.From = senderEmailmsg.FromName = name' smtp认证的关键msg.mailserverusername="info@123.com" ‘邮箱账户,需完整地址msg.mailserverpassword="password" '输入你的邮箱密码' 将收信人的资料加入组件msg.AddRecipient recipient' 设定信件的主题msg.Subject = subject' 设定信件的主体内容msg.body = body & vbcrlf & vbcrlf & "其他联系方式:" & other' 送出表单资料为电子邮件 ,并指定发信服务器 SMTPif not msg.Send("mail.123.com" ) thenResponse.write "<pre>" & msg.log & "</pre>"elseResponse.write "信件成功寄出,谢谢您的留言!!"Response.write "<a href=javascript:history.go(-1)>返回</a>"end ifmsg.Closeset msg=nothingelse response.write "请将内容填写完整!!"end if%></body></html>