逸云 - 秦皇岛最好的网站建设、网站制作、网络推广与SEO网站优化团队

逸云团队网络技术专家在线

秦皇岛网站制作 | 秦皇岛网站建设 | 秦皇岛网络公司 | 网页制作 | 做网站 | 秦皇岛SEO | 网站优化 | 网站推广 | 网络营销 | 百度排名推广 | 营销型网站制作

我们提供企业网站建设与推广全套解决方案,致力于提升秦皇岛本地企业的全国竞争能力,帮助你成倍提高公司销售业绩!

导航

« ASP防SQL注入怎样学习炒股 »

jmail 发邮件 完整实例

<%
'括号::发送邮件服务器,邮件接收人,发送人,登录邮箱的用户名,登录邮箱的密码,邮件主题,邮件内容
function sendmail(smtp,sendto,from,user,pwd,subject,body)
Set jmail = Server.CreateObject("JMAIL.Message") '建立发送邮件的对象
jmail.silent = true '屏蔽例外错误,返回FALSE跟TRUE两值j
jmail.logging = true '启用邮件日志
'加上如下语句,否则还有可能出现乱码的可能性:
jmail.Charset = "GB2312" '邮件的文字编码为国标
jmail.ContentTransferEncoding = "base64"   
jmail.Encoding = "base64"   
jmail.ISOEncodeHeaders = false

'jmail.ContentType = "text/html" '邮件的格式为HTML格式 -- 有此句则发送附件时为乱码
jmail.AddRecipient sendto '邮件收件人的地址
jmail.From = from '发件人的E-MAIL地址
jmail.MailServerUserName = user '登录邮件服务器所需的用户名
jmail.MailServerPassword = pwd '登录邮件服务器所需的密码
jmail.Subject = subject '邮件的标题
jmail.Body = body '邮件的内容
'jmail.AddAttachment Server.MapPath("login.gif")'附件--不能有此句:jmail.ContentType = "text/html"
'Jmail.AddAttachment Server.MapPath("b.rar")       '否则附件会变成乱码
jmail.Priority = 3 '邮件的紧急程序,1 为最快,5 为最慢, 3 为默认值
if jmail.send(smtp)=false then'执行邮件发送(通过邮件服务器地址)
     sendmail=0
else
     sendmail=1
end if
jmail.Close
end function

doWhat=request("doWhat")
Content=request("Content")

if doWhat="sendEmail" then
domains=request("domains")
uName=request("uName")
uPw=request("uPw")
sendTo=request("sendTo")
Title=request("Title")
'邮件服务器
select case domains
case "163"
   domains="smtp.163.com"
   uName=uName&"@163.com"
case "sina"
   domains="smtp.sina.com"
   uName=uName&"@sina.com"
case "126"
   domains="smtp.126.com"
   uName=uName&"@126.com"
case "yahoo"
   domains="smtp.yahoo.com.cn"
   uName=uName&"@yahoo.com.cn"
case "21cn"
   domains="smtp.21cn.com"
   uName=uName&"@21cn.com"
case "sohu"
   domains="smtp.sohu.com"
   uName=uName&"@sohu.com"
case "tom"
   domains="smtp.tom.com"
   uName=uName&"@tom.com"
case "188"
   domains="smtp.188.com"
   uName=uName&"@188.com"
case "gmail"
   domains="smtp.gmail.com"
   uName=uName&"@gmail.com"
end select

if domains="" or uName="" or uPw="" or sendTo="" or Title="" or Content="" then
   response.write"<script>alert('请填写完整所有内容!');history.back(-1);</script>"
   response.End()
end if

'调用发邮件函数
isOK=sendmail(domains,sendTo,uName,uName,uPw,Title,Content)
if isOK=1 then
   response.write"<script>alert('邮件已经成功发送!');history.back(-1);</script>"
   response.End()
else
   response.write"<script>alert('发送失败,请检查您的用户名跟密码是否正确!');history.back(-1);</script>"
   response.End()
end if
end if
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>推荐给朋友</title>
</head>

<body>
<form id="form1" name="form1" method="post" action="ListFriend.asp">
   <table width="500" border="0" align="center" cellpadding="0" cellspacing="0">
     <tr>
       <td width="71" height="30" align="right">邮箱:</td>
       <td width="429" height="30">
    <select size="1" name="domains">
         <option value="163" selected="selected" >@163.com 网易</option>
         <option value="sina">@sina.com 新浪</option>
         <option value="126">@126.com 网易</option>
         <option value="yahoo">@yahoo.com.cn 雅虎</option>
         <option value="21cn">@21cn.com</option>
         <option value="sohu">@sohu.com 搜狐</option>
         <option value="tom">@tom.com</option>
         <option value="188">@188.com</option>
         <option value="gmail">@gmail.com</option>
       </select>
    * </td>
     </tr>
     <tr>
       <td height="30" align="right">用户名:</td>
       <td height="30"><input size="23" name="uName" />
       *(例:myemail)</td>
     </tr>
     <tr>
       <td height="30" align="right">密码:</td>
       <td height="30"><input type="password" size="19" name="uPw" />
         *</td>
     </tr>
     <tr>
       <td height="30" align="right">收件人:</td>
       <td height="30"><input name="sendTo" type="text" id="sendTo" size="35" />
       *(例:huang@126.com)</td>
     </tr>
     <tr>
       <td height="30" align="right">标题:</td>
       <td height="30"><input name="Title" type="text" id="Title" value="有一款我觉得超值的手机,也介绍给你!" size="50" />
       *</td>
     </tr>
     <tr>
       <td height="30" align="right">内容:</td>
       <td height="30"><textarea name="Content" cols="50" rows="6" id="Content"><%=Content%></textarea>
       *</td>
     </tr>
     <tr>
       <td height="30" align="right"><input name="doWhat" type="hidden" id="doWhat" value="sendEmail" /></td>
       <td height="30"><input    tabindex="4" type="submit" value=" 发 送 " name="sub" style="height:1.67em;width:5.0em;font-size:13px" />
         (点击发送后请稍等提示...)</td>
     </tr>
   </table>
</form>
</body>
</html>



  • 相关文章:

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

最新评论及回复

最近发表

提供网站建设、网站制作、网站推广、SEO搜索引擎优化

Copyright@724ad.com. All Rights Reserved. 冀ICP备09002487号