<%@ LANGUAGE = VBScript.Encode %>
<!--#include file="../Include/conn.asp" -->
<!--#include file="../Include/ConnDatabase.asp" -->
<%
'=====================================
'天天企业网站管理系统  TianTianCMS
'天天网络科技工作室版权所有
'官方客服中心 http://www.ip126.com
'微信公众号 ip126com
'QQ:530051328 mail:bbfhq@163.com
'=====================================
%>
<HTML xmlns="http://www.w3.org/1999/xhtml">
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312" />
<TITLE>邮件列表管理</TITLE>
<link rel="stylesheet" href="Images/Admin.css">
<script language=javascript src="../Include/mouse_on_title.js"></script>
<!--kindeditor编辑器-->
		<link rel="stylesheet" href="../KindEditor/themes/default/default.css" />
		<script charset="utf-8" src="../KindEditor/kindeditor-min.js"></script>
		<script charset="utf-8" src="../KindEditor/lang/zh_CN.js"></script>
		<script>
			var editor;			
			KindEditor.ready(function(K) {
				editor = K.create('textarea[name="mail_bodyhtm"]', {
					resizeType : 2,//0:设置kindeditor编辑器大小不可改变; 1:只能该变高度; 2:可以改变高度和宽度
					afterBlur: function(){this.sync();},//失去焦点执行this获得值
					allowPreviewEmoticons : false,
					allowImageUpload : false,					
					items : [
						'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
						'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
						'insertunorderedlist', '|', 'emoticons', 'image', 'link']
				});
			});
		</script>
<!--kindeditor编辑器END-->
<script language="javascript">
<!--
//验证邮箱正确性
function checkemail(email){
var str=email;
//在JavaScript中，正则表达式只能使用"/"开头和结束，不能使用双引号
var Expression=/\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/; 
var objExp=new RegExp(Expression);
if(objExp.test(str)==true){
return true;
}else{
return false;
}
} 

//说明字节数限制，与下面配合=========
String.prototype.Length=function(){
temp=this.replace(/([^\x00-\xff])/g,"$1$1");
return temp.length
}

function formcheck(){
	if (document.email.email.value=="" )
	{
	  alert("请填邮箱")
	  document.email.email.focus()
	  return false
	 }
    if((!checkemail(email.email.value))&&(document.email.email.value!=""))
	{
    alert("您输入Email地址不正确，请重新输入!");
    document.email.email.focus();
    return false;
    }
if (document.email.mail_subject.value=="" )
	{
	  alert("请填邮件主题")
	  document.email.mail_subject.focus()
	  return false
	 }
if (document.email.mail_body.value.length>5000)  //字节数限制，与上面配合。
     {
	 alert("邮件内容长度要求<%=5000%>字节(<%=2500%>汉字)内，请重新输入！");
	  return false
  }

}
// --></script>
</HEAD>


<%if Instr(session("AdminPurview"),"|46,")=0 then
  response.write ("<br><br><div align=""center""><font style=""color:red; font-size:9pt; "")>您没有管理该模块的权限！</font></div>")
  response.end
end If%>
<BODY>
<script language=javascript>
<!--
function CheckAll(form){
for (var i=0;i<form.elements.length;i++){
var e = form.elements[i];
if (e.name != 'chkall') e.checked = form.chkall.checked; 
}
}
-->
</script>
</head>
<BODY>

<%dim action,hy
Language=request("Language")
hy=" 欢迎光临 "
If Language="EN" Then hy=" Welcome TO "
'call SiteInfo
action=request("action")
if action="send" then
call sendmail()
else
email=request.ServerVariables("query_string")
%>
<form action="admin_Maillist_to.asp" method=post  name="email" onSubmit="return formcheck()">
<table width="700" border="1" align="CENTER" style="border-collapse: collapse; border-style: dotted; border-width: 0px" bordercolor="#333333" cellspacing="0" cellpadding="2" style="word-break:break-all">
<tr><td colspan=4 bgcolor="#BDBEDE" height=28 align=center><B>向会员发送邮件</b></td></tr>
<tr><td colspan=4 align=center><font color="#ff0000"> 注意：由于很多邮局、尤其是免费邮箱群发邮件都受监测，可能因过密或内容相同而被暂时或永久禁止发信功能，如果需经常群发邮件的建议购买不受限制的企业邮局！</font></td></TR>
<tr><td width=20% align=center>收件人</td>
<td><TEXTAREA NAME="email" rows=5 style="width=80% ; overflow:auto;"><%=email%></TEXTAREA>&nbsp; <img align=top src="../images/memo.gif" alt="填写收件人邮箱地址<br>多个邮箱以半角逗号或分号隔开<br><font color=red>千万不要发垃圾邮件哦~后果很严重</font>"> </td></TR>
<tr><td width=80% align=center>邮件主题</td><td><input type=text name=mail_subject style="width=53%;" maxlength=50>&nbsp; <img src=../images/memo.gif alt="填写邮件主题<br><font color=red>技巧：好的主题吸引人点击阅读<br>差的主题可能会被直接删除</font>"> </td></TR>
	<tr>                                                                   
    <td width=20% align=center>邮件格式</td>                                                                   
    <td width="86%" height="26"><input type="radio" name="radiobutton" value="text" checked style="border:1px black solid">                                                                   
      文本邮件&nbsp; <input type="radio" name="radiobutton" value="html" style="border:1px black solid">                                                                          
        HTML邮件&nbsp;&nbsp;<font color="#ff0000"> 下面两个内容框要根据选择的邮件格式对应填写，不能同时填写！</font></td>                                                                           
  </tr> 
<tr><td width=20% align=center>文本格式邮件内容<br><br><font color=red>（1000字符以内）</font></td><td><TEXTAREA NAME="mail_body" ROWS="10" style="width=80% ; overflow:auto;"></TEXTAREA>&nbsp; <img align=top src=../images/memo.gif alt="支持文本格式<br>若收件人的邮箱不支持html<br>可选择此方式"> </td></TR>
<tr><td width=20% align=center>HTML格式邮件内容<br><br><font color=red>（1000字符以内）</font></td><td><textarea id="editor" name="mail_bodyhtm"  style="width:550px;height:280px;visibility:visible"></textarea>&nbsp; <img align=top src=../images/memo.gif alt="支持html<br>但若收件人的邮箱不支持html<br>则看到的是一堆代码而矣"> </td></TR>
 
  <tr>                                                                          
    <td width=20% align=center>邮件等级</td>                                                                          
    <td width="86%" height="26"><input type="radio" name="dengji" value="1" style="border:1px black solid">                                                                          
      加急&nbsp; <input type="radio" name="dengji" value="3" checked style="border:1px black solid">                                                                          
      普通&nbsp; <input type="radio" name="dengji" value="5" style="border:1px black solid">                                                                          
      低级&nbsp;&nbsp;</td>                                                                          
  </tr>
  <tr>                                                                   
    <td width=20% align=center>邮件语言</td>                                                                   
    <td width="86%" height="26"><input type="radio" name="Language" value="Ch" checked style="border:1px black solid">                                                                   
      中文&nbsp; <input type="radio" name="Language" value="En" style="border:1px black solid">                                                                          
        英文&nbsp;</td>                                                                           
  </tr> 
<tr><td colspan=2 bgcolor='#DADAE9' align=center>
<input type=hidden name=action value="send">
<input type=submit value="立即发送">
&nbsp; &nbsp; &nbsp; <input type="reset" value="重新填写">
</table>
</form>
<%end If

sub sendmail()
If Request("mail_body") <> "" and Request("mail_bodyhtm") <> "" Then  
response.write "<script LANGUAGE='javascript'>alert('温馨小提示：两种格式邮件内容不能同时填写!');history.go(-1);</script>"
Response.End
End If
If Request("radiobutton") = "text" and Request("mail_body")="" Then  
response.write "<script LANGUAGE='javascript'>alert('温馨小提示：选择文本格式邮件请将内容填写在文本格式邮件内容框!');history.go(-1);</script>"
Response.End
End If
If Request("radiobutton") = "html" and Request("mail_bodyhtm")="" Then  
response.write "<script LANGUAGE='javascript'>alert('温馨小提示：选择HTML格式邮件请将内容填写在HTML格式邮件内容框!');history.go(-1);</script>"
Response.End
End If
mail_subject=trim(request("mail_subject"))
If Request("mail_body") <> "" then
mail_body=Request("mail_body")
Else
mail_body=Request("mail_bodyhtm")
End if
dim mail_subject,mail_body,email
Dim x,io,sendok,i
mail_subject=trim(request("mail_subject"))
email=trim(request("email"))
email=replace(email," ","")
email=replace(email,"；",";")
email=replace(email,"，",";")
email=replace(email,",",";")
if email="" or mail_subject="" or mail_body="" Then
response.write "<script language='javascript'>"
response.write "alert('出错了，收件人信箱、邮件主题、邮件内容必须完整填写。');"
response.write "location.href='javascript:history.go(-1)';"
response.write "</script>"
response.end
end if
if UBound(split(email,";"))>20 then
response.write "<script language='javascript'>"
response.write "alert('出错了，您填写的收件人太多了,限20个！~~');"
response.write "location.href='javascript:history.go(-1)';"
response.write "</script>"
response.end
end if

mail_body=mail_body+"◆"&hy&""+SiteTitle+"http://"+SiteUrl	
x=split(email,";")

Dim aJMail   
Set aJMail=Server.CreateObject("JMail.Message")   
If aJMail Is Nothing Then  
response.write "<script LANGUAGE='javascript'>alert('温馨小提示：服务器不支持JMail.Message组件，请立即安装此组件，此组件用于邮件发送!');history.go(-1);</script>"
Response.End
End   If

Dim JMail,ErrStr
for io=0 to Ubound(x)
'jmail邮件组件发送邮件开始，下面的值要先取得
Set jmail = Server.CreateObject("JMail.Message") 
jmail.silent = true '屏蔽例外错误，返回FALSE跟TRUE两值
jmail.Charset = "gb2312"  '邮件的文字编码为国标
If Request.form("radiobutton") = "html" Then
jmail.ContentType = "text/html"    '邮件的格式为HTML格式
end if
jmail.MailServerUserName = mailname '输入smtp服务器验证登陆名 （邮局中任何一个用户的Email地址） 
jmail.MailServerPassword = mailpass '输入smtp服务器验证密码 （用户Email帐号对应的密码） 
jmail.From = mailform '发信人信箱，因服务器反垃圾邮件，此信箱必须与发信服务器同域用户的信箱！ 
jmail.FromName = SiteTitle '发件人姓名 
jmail.AddRecipient(x(io)) '收件人Email 
jmail.Subject = mail_subject '邮件的标题 
jmail.Body = mail_body '邮件的内容
JMail.Priority = Request.form("dengji")      '邮件的紧急程序 
jmail.Send (mailsmtp) '执行邮件发送smtp服务器地址（企业邮局地址）
ErrStr =jmail.errormessage
jmail.close 
set jmail = nothing '关闭对象
next  

if ErrStr="" then
response.write "<script language='javascript'>alert('恭喜，邮件已经发出。');location.href='admin_Maillist.asp';</script>"
Response.End
else
Response.Write "<script>alert('发送邮件失败！\n\n失败原因："&ErrStr&"！\n\n点击确定返回！');history.back();</Script>"
Response.End 
end if
end sub
%>