<%@ Language=VBScript %>
<%server.ScriptTimeout=15

                                                                                                                                          
if Request("flag")=1 then
	SMTPServer=trim(Application("SMTPServer"))
	'SMTPServer="zjuem.zju.edu.cn"
	'SMTPServer_username="jinjd"
	' SMTPServer_passwd="811016"
	SMTPServer_username=Application("SMTPServer_username")
   SMTPServer_passwd=Application("SMTPServer_passwd")
	SystemEmail=trim(Application("SystemEmail"))
	SenderName=trim(Application("SenderName"))
	email=trim(Request("to_who"))
	topic=trim(Request("topic"))
	mailbody=trim(Request("mailbody"))
	
	on error resume next
	dim msg,SendMail
	Set msg = Server.CreateObject("JMail.Message")

		msg.silent = true
		msg.Logging = true
		msg.Charset = "gb2312"
		msg.MailServerUserName = SMTPServer_username
		msg.MailServerPassword = SMTPServer_passwd
		msg.From = SystemEmail
		msg.FromName = SenderName
		msg.AddRecipient email
		msg.Subject = topic
		msg.Body = mailbody
		msg.Send (SMTPServer)
	set msg=nothing
	if err then 
	SendMail=err.description
	err.clear
	else
	SendMail="ok"
	end if

  
  
%>

<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY  ><LINK 
href="css/default.css" rel=stylesheet>
	<%if SendMail="ok" then%>
<p align=center><BR><BR>邮件发送成功！
</P>
<p align=center>系统已经将你的信件发到<%=email%>处了&nbsp;&nbsp;
</P>
	<%else%>
	<p align=center>邮件发送失败！
	</P align=center>
	<p align=center>失败原因：<%=SendMail%>&nbsp;&nbsp;
	</P>
	<%end if%>
<p><a href=mail_manage.asp >返 回</a></p>
</FORM>
</BODY>
</HTML>
<%else%>
<SCRIPT language=JavaScript>

function is_email(str)
{ if((str.indexOf("@")==-1)||(str.indexOf(".")==-1)){
	
	return false;
	}
	return true;
}
function checkform(){
	 	
	if( inputform.to_who.value =="") {
                alert("\请输入EMail地址!!")
                inputform.to_who.focus();
                return false;
        }
	if(!is_email(inputform.to_who.value))
	{ alert("非法的EMail地址！");
		inputform.to_who.focus();
	return false;
	}
	return true;
}
</script>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY  bgcolor=#FFFBE7>
<LINK 
href="css/default.css" rel=stylesheet>
<BR>
<TABLE cellSpacing=0 width="100%" align=center bgColor=#FFFBE7 cellPadding=5>
        <TBODY bgColor=#FFFBE7>
        <TR>
		<TD align=center>发送个人邮件</TD><TD><font size=5><a href=mail_manage.asp>返回</font></a></TD>
		</TR>
</tbody>
</table>	
<FORM action="mail_for_person.asp" method=POST id=form1 name=inputform onsubmit=return(checkform())>
<INPUT type="hidden" id=text1 name=flag value=1>
<TABLE cellSpacing=1 width="100%" align=center bgColor=#FFCC33 cellPadding=5>
        <TBODY bgColor=#FFFBE7>
        <TR>
		<TD>&nbsp;&nbsp;收信人地址：</TD>
		<TD><INPUT class=input2 type="text" id=text1 name=to_who size=50></TD>
	</TR>
	<TR>
		<TD>&nbsp;&nbsp;主题：</TD>
		<TD ><INPUT  class=input2 type="text" id=text2 name=topic  size=50></TD>
	</TR>
	<TR>
		<TD colspan=2 align=center>主体内容：</TD>
		
	</TR>
	<TR>
		
		<TD colspan=2 align=center><TEXTAREA  class=input2 rows=16 cols=80 id=textarea1 name=mailbody></TEXTAREA></TD>
	</TR>
	<TR align=center>
		<TD  align=center colspan=2><INPUT  class=input2 type="submit" value="发 送" id=submit1 name=submit1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		<INPUT  class=input2 type="reset" value="取 消" id=reset1 name=reset1></TD>
	</TR>
</TABLE>

</FORM>
</BODY>
</HTML>
<%end if%>