email_m.jsp
上传用户:jhtang88
上传日期:2014-01-27
资源大小:28528k
文件大小:7k
源码类别:

Jsp/Servlet

开发平台:

Java

  1. <%@ page contentType="text/html; charset=utf-8" %>
  2. <%@ include file="../inc/inc.jsp" %>
  3. <%@ page import="cn.js.fan.module.cms.*"%>
  4. <%@ page import="cn.js.fan.web.*"%>
  5. <%@ page import="cn.js.fan.base.*"%>
  6. <%@ page import="cn.js.fan.util.*"%>
  7. <%@ page import="com.redmoon.forum.*"%>
  8. <%@ page import="com.redmoon.forum.person.*"%>
  9. <%@ page import="cn.js.fan.module.pvg.*" %>
  10. <%@ taglib uri="/WEB-INF/tlds/LabelTag.tld" prefix="lt" %>
  11. <jsp:useBean id="StrUtil" scope="page" class="cn.js.fan.util.StrUtil"/>
  12. <html><head>
  13. <meta http-equiv="pragma" content="no-cache">
  14. <meta http-equiv="Cache-Control" content="no-cache, must-revalidate">
  15. <meta http-equiv="expires" content="wed, 26 Feb 1997 08:21:57 GMT">
  16. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  17. <title><lt:Label res="res.label.email_m" key="group_send_email"/></title>
  18. <link rel="stylesheet" href="../common.css">
  19. <script language="JavaScript">
  20. <!--
  21. function selTemplate(id)
  22. {
  23. form1.templateId.value = id;
  24. window.location.href = "../email_m.jsp?templateId=" + id;
  25. }
  26. function form1_onsubmit() {
  27. if (form1.templateId.value==-1) {
  28. alert("<%=SkinUtil.LoadString(request,"res.label.email_m","select_template")%>");
  29. return false;
  30. }
  31. }
  32. //-->
  33. </script>
  34. <link href="common.css" rel="stylesheet" type="text/css">
  35. <LINK href="cms/default.css" type=text/css rel=stylesheet>
  36. <body bgcolor="#FFFFFF" topmargin='0' leftmargin='0'>
  37. <table width='100%' cellpadding='0' cellspacing='0' >
  38.   <tr>
  39.     <td class="head">Email<lt:Label res="res.label.email_m" key="group_send_mgr"/></td>
  40.   </tr>
  41. </table>
  42. <jsp:useBean id="privilege" scope="page" class="cn.js.fan.module.pvg.Privilege"/>
  43. <jsp:useBean id="sendmail" scope="page" class="cn.js.fan.mail.SendMail"/>
  44. <%
  45. if (!privilege.isUserPrivValid(request, Priv.PRIV_EMAIL))
  46. {
  47. out.print(cn.js.fan.web.SkinUtil.makeErrMsg(request, cn.js.fan.web.SkinUtil.LoadString(request, "pvg_invalid")));
  48. return;
  49. }
  50. int templateId = -1;
  51. try {
  52. templateId = ParamUtil.getInt(request, "templateId");
  53. }
  54. catch (ErrMsgException e) {
  55. }
  56. Document template = new Document();
  57. if (templateId!=-1) {
  58. template = template.getDocument(templateId);
  59. }
  60. String senderName = ParamUtil.get(request, "senderName");
  61. String subject = ParamUtil.get(request, "subject");
  62. if (subject.equals("")) {
  63. subject = StrUtil.getNullString(template.getTitle());
  64. }
  65. %>
  66. <br>
  67. <TABLE class="frame_gray"  
  68. cellSpacing=0 cellPadding=0 width="95%" align=center>
  69.   <TBODY>
  70.     <TR>
  71.       <TD valign="top" bgcolor="#FFFBFF" class="thead">Email<lt:Label res="res.label.email_m" key="group_send"/></TD>
  72.     </TR>
  73.     <TR>
  74.       <TD height=200 valign="top" bgcolor="#FFFBFF"><br>
  75.         <table width="98%" border='0' align="center" cellpadding='0' cellspacing='0'>
  76.           <form name="form1" action="?" method="post" onSubmit="return form1_onsubmit()">
  77.   <tr>
  78.             <td height=20 align="left"><span class="unnamed2"><a href="javascript:showModalDialog('doc_template_select_frame.jsp',window.self,'dialogWidth:640px;dialogHeight:480px;status:no;help:no;')">
  79.               </a></span></td>
  80.           <td width="11%" align="left"><span class="unnamed2"><lt:Label res="res.label.email_m" key="template_ID"/></span></td>
  81.             <td width="83%" height="28" align="left"><span class="unnamed2">
  82.             <input name="templateId" class="singleboarder" value="<%=templateId%>" size=3 readonly>
  83. <a href="javascript:showModalDialog('cms/doc_template_select_frame.jsp',window.self,'dialogWidth:800px;dialogHeight:480px;status:no;help:no;')">
  84.             <lt:Label res="res.label.email_m" key="select_template"/></a>&nbsp;( -1 <lt:Label res="res.label.email_m" key="has_not_selected_template"/> ) <input type="hidden" name="op" value="send">
  85.             ( <lt:Label res="res.label.email_m" key="msg"/> )</span></td>
  86.   </tr>
  87.   <tr>
  88.     <td height=20 align="left">&nbsp;</td>
  89.     <td height=20 align="left"><span class="unnamed2"><lt:Label res="res.label.email_m" key="sender"/></span></td>
  90.     <td height="28" align="left"><span class="unnamed2">
  91.       <input name="senderName" class="singleboarder" value="<%=senderName.equals("")?Global.AppName:senderName%>" size=20>
  92.     </span></td>
  93.     </tr>
  94.   <tr>
  95.     <td height=20 align="left">&nbsp;</td>
  96.     <td height=20 align="left"><lt:Label res="res.label.email_m" key="topic"/></td>
  97.     <td height="28" align="left"><span class="unnamed2">
  98.       <input name="subject" class="singleboarder" value="<%=subject%>" size=40>
  99.     </span></td>
  100.     </tr>
  101.   <tr>
  102.     <td height=38 colspan="2" align="left">&nbsp;</td>
  103.     <td height="38" align="left"><span class="unnamed2">
  104.       <input type="submit" value="<%=SkinUtil.LoadString(request,"res.label.email_m","send_mail")%>">
  105.     </span></td>
  106.     </tr>
  107.           <tr>
  108.             <td colspan="3" valign="top"><table width="100%" border='0' cellspacing='0' cellpadding='0'>
  109.                 <tr >
  110.                   <td width="6%" class="stable">        
  111.                 <tr>
  112.                     <td height="23" colspan=3 align="center" class="stable">
  113. <%
  114. if (templateId!=-1)
  115. out.print(template.getContent(1));
  116. %>
  117.     </td>
  118.                 </tr></form>
  119.         </TABLE>
  120.     <br>  
  121. </td>
  122.     </tr>
  123. </table></TD>
  124.     </TR>
  125.   </TBODY>
  126.   <%
  127. String op = ParamUtil.get(request, "op");
  128. if (op.equals("send")) {
  129. String mailserver = Global.getSmtpServer();
  130. int smtp_port = Global.getSmtpPort();
  131. String name = Global.getSmtpUser();
  132. String pwd_raw = Global.getSmtpPwd();
  133. sendmail.initSession(mailserver, smtp_port, name, pwd_raw);
  134. String sql = "select name from sq_user ORDER BY RegDate desc";
  135. UserDb user = new UserDb();
  136. int count = user.getUserCount(sql);
  137. ObjectBlockIterator ir = user.getUsers(sql, 0, count);
  138. senderName = StrUtil.GBToUnicode(senderName);
  139. senderName += "<" + Global.getEmail() + ">";
  140. String content = template.getContent(1);
  141. int failcount = 0;
  142.     while (ir.hasNext()) {
  143. user = (UserDb)ir.next();
  144. // out.print("username=" + user.getName());
  145. %>
  146.   <table width="90%"  border="0" align="center" cellpadding="0" cellspacing="0">
  147.     <tr>
  148.       <td><%
  149. String username = user.getName();
  150. // sendmail.setmailFooterHTML("<br>------镇江人家------");
  151. // sendmail.getMailInfo(application, request);
  152. String to = user.getEmail();
  153. String content1 = content.replaceAll("\$name", username);
  154. //if (username.equals("bluewind")) {
  155. sendmail.initMsg(to, senderName, subject, content1, true);
  156. if ( sendmail.send())
  157.    ; // out.println(username + " " + to + " 邮件发送成功!<BR>");
  158. else
  159. {
  160. failcount++;
  161.     out.println(username + " " + to + SkinUtil.LoadString(request,"res.label.email_m","reason") +sendmail.getErrMsg());
  162. }
  163. sendmail.clear();
  164. //}
  165. Thread.sleep(5);
  166. %>
  167.       </td>
  168.     </tr>
  169. </table>
  170.   <%}
  171. out.print("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + SkinUtil.LoadString(request,"res.label.email_m","counts of fail")  + failcount + SkinUtil.LoadString(request,"res.label.email_m","man"));
  172. }%>
  173. <br>
  174. </td>
  175. </tr>
  176. </td>
  177. </tr>
  178. </body>                                        
  179. </html>                            
  180.