sendmail.asp
上传用户:qyswxdl
上传日期:2013-06-01
资源大小:1373k
文件大小:4k
源码类别:

家庭/个人应用

开发平台:

ASP/ASPX

  1. <!--#include file="../checkpost.asp"-->
  2. <!--#include file="articleconn.asp"-->
  3. <!--#include file="security.asp"-->
  4. <%if session("flag")>3 then
  5.     response.write "<br><p align=center>您的操作权限不够!</p>"
  6.     response.end
  7. end if
  8. %>
  9. <html>
  10. <head>
  11. <meta http-equiv="Content-Language" content="zh-cn">
  12. <meta name="GENERATOR" content="Microsoft FrontPage 5.0">
  13. <meta name="ProgId" content="FrontPage.Editor.Document">
  14. <LINK href="inc/Admin_STYLE.CSS" rel="stylesheet" type="text/css">
  15. </head>
  16. <title></title>
  17. <body >
  18. <form name="sendmail" action="?action=send" method="post">
  19.   <div align="center">
  20. <center>
  21.       <table width="474" border="0" align="center" cellpadding="4" cellspacing="1" class="border"  style="border-collapse: collapse">
  22.         <tr bgcolor="#429AEF"> 
  23.           <td height="23" colspan="2" align="center" ><strong><font color="#FFFFFF">发 
  24.             送 邮 件</font></strong></td>
  25.       </tr>
  26.         <tr> 
  27.           <td width="76" height="25" align="right" valign="middle" class="tdbg">  
  28.             <div align="center">发信人地址:</div></td>
  29.           <td width="382" height="25" class="tdbg"> 
  30.             <input type="text" name="frommail" size="20"> </td>
  31.       </tr>
  32.         <tr> 
  33.           <td width="76" height="25" align="right" valign="middle" class="tdbg"> 
  34.             <div align="center">收信人地址: 
  35.             </div></td>
  36.           <td width="382" height="25" class="tdbg"> 
  37.             <input type="text" name="tomail" size="20" value="<%=request("email")%>"> 
  38.         (如果为空,则向所有会员群发!) </td>
  39.       </tr>
  40.         <tr> 
  41.           <td width="76" height="25" class="tdbg"> 
  42.             <div align="center">信件标题:</div></td>
  43.           <td width="382" height="25" class="tdbg"> 
  44.             <input type="text" name="mailsubject" size="49" value="影视通知!"> </td>
  45.       </tr>
  46.         <tr> 
  47.           <td width="76" height="25" valign="top" class="tdbg">&nbsp; 
  48.             <div align="center">信件内容:</div></td>
  49.           <td width="382" height="25" class="tdbg"> 
  50.             <textarea name="mailbody" cols="48" rows="8"></textarea> <br>
  51.         </td>
  52.       </tr>
  53.         <tr> 
  54.           <td height="10" colspan="2" align="center" class="tdbg">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  55.             <input type="submit" name="Submit" value="发送">
  56.         <input type="reset" name="Submit" value="取消"> </td>
  57.       </tr>
  58.     </table>
  59.     </center>
  60.   </div>
  61. </form>
  62. </body>
  63. <%
  64. if request("action") = "send" then
  65. frommail = Trim(Request.Form("frommail"))
  66. tomail = Trim(Request.Form("tomail"))
  67. mailsubject = Trim(Request.Form("mailsubject"))
  68. mailbody = Trim(Request.Form("mailbody"))
  69. smtpserver ="XXX"
  70. smtpuser ="XXXX"
  71. smtppwd ="xxxx"
  72. if tomail<>"" then
  73. ' 创建jmail对象:
  74.     Set JMail = Server.CreateObject("JMail.Message")
  75.      '身分验证
  76.         JMail.MailServerUserName = smtpuser
  77.         JMail.MailServerPassword = smtppwd    
  78. JMail.Charset ="gb2312"
  79. JMail.ContentType = "text/html"
  80. JMail.from = frommail
  81. JMail.AddRecipient(""&tomail&"")
  82. JMail.Subject = mailsubject  
  83. JMail.Body = mailbody
  84. JMail.Priority = 3   
  85.         JMail.Send(smtpserver)
  86.         JMail.Close()
  87.     Set JMail=nothing
  88. else
  89. ' 创建jmail对象:
  90.     Set JMail = Server.CreateObject("JMail.Message")
  91.             '身分验证
  92.         JMail.MailServerUserName = smtpuser
  93.         JMail.MailServerPassword = smtppwd
  94.     JMail.Charset ="gb2312"
  95.     JMail.ContentType = "text/html"
  96. JMail.from = frommail
  97. sql="select email from users"
  98. set rs=conn.execute(sql)
  99. Response.Write("正在邮件群发.................." )
  100. do while not rs.eof 
  101. JMail.AddRecipient(""&rs("email")&"")
  102. RS.MoveNext
  103. Loop
  104. rs.close
  105. JMail.Subject = mailsubject  
  106. JMail.Body = mailbody
  107. JMail.Priority = 3   
  108.         JMail.Send(smtpserver)
  109.         JMail.Close()
  110.     Set JMail=nothing
  111. end if
  112. Response.Write "<script>alert(""发送成功"");location.href=""sendmail.asp"";</script>"
  113. Response.End
  114. end if
  115. %>
  116. </html>