<?php
if (!defined('USING_SYSTEM')) exit;
?>
<!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=utf-8" />
<link type="text/css" rel="stylesheet" href="admin/images/page.css" />
<script type="text/javascript" src="skins/common/images/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="admin/images/page.js"></script>
<script type="text/javascript">
$(document).ready(function(e) {
    $('#sendMailBtn').on('click', function() {
		window.parent.showWindow($('#sendTestWindow').html(), [function(win) {
			window.parent.showWindowMask(win);
			$.ajax({
				type:'POST',
				url:'admin.php?ac=p105&get=ajax&do=sendTest',
				cache: false,
				data: {ssl:$('#smtpSslTxt').val(),port:$('#smtpPortTxt').val(),smtp:$('#smtpSmtpTxt').val(),username:$('#smtpUsernameTxt').val(),password:$('#smtpPasswordTxt').val(),from:$('#smtpFromTxt').val(),to:window.parent.$('#toTxt').val(),title:window.parent.$('#titleTxt').val(),html:window.parent.$('#htmlTxt').val()},
				success: function(j) {
					j = $.parseJSON(j);
					if(j.result == '0') {
						alert('发送失败，详细信息：\n'+j.msg);
					} else {
						alert('发送成功');
						window.parent.hideWindow();
					}
					window.parent.hideWindowMask(win);
				}
			});
			//*/
		}]);
	});
});
</script>
<title>Filiant Control Panel</title>
</head>
<body>
<div class="bigTips"<?php echo ($tips=='')?'':' style="display:block;"' ?>><?php echo $tips ?></div>
<form id="mainForm" action="" method="post">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <th colspan="3">SMTP设置</th>
  </tr>
  <tr>
    <td class="title" width="150">SSL</td>
    <td width="400" class="dropdown">
      <select name="smtpSslTxt" id="smtpSslTxt">
        <option value="1" selected="selected">是</option>
        <option value="0">否</option>
      </select>
<script type="text/javascript">
$('[name="smtpSslTxt"]').val('<?php echo $_SLEX['smtp']['ssl'] ? '1' : '0' ?>');
</script>
    </td>
    <td class="tips">根据邮箱服务提供商的说明来决定是否开启</td>
  </tr>
  <tr>
    <td class="title">端口</td>
    <td><input name="smtpPortTxt" id="smtpPortTxt" type="text" class="textbox" value="<?php echo $_SLEX['smtp']['port'] ?>" /></td>
    <td class="tips">邮件服务器端口，一般为25</td>
  </tr>
  <tr>
    <td class="title">服务器</td>
    <td><input name="smtpSmtpTxt" id="smtpSmtpTxt" type="text" class="textbox" value="<?php echo $_SLEX['smtp']['smtp'] ?>" /></td>
    <td class="tips">例如 smtp.maiyun.net</td>
  </tr>
  <tr>
    <td class="title">帐号</td>
    <td><input name="smtpUsernameTxt" id="smtpUsernameTxt" type="text" class="textbox" value="<?php echo $_SLEX['smtp']['username'] ?>" /></td>
    <td class="tips">例如 admin@maiyun.net</td>
  </tr>
  <tr>
    <td class="title">密码</td>
    <td><input name="smtpPasswordTxt" id="smtpPasswordTxt" type="text" class="textbox" value="<?php echo $_SLEX['smtp']['password'] ?>" /></td>
    <td class="tips">例如 这个不能让你知道 :P</td>
  </tr>
  <tr>
    <td class="title">发件信箱</td>
    <td><input name="smtpFromTxt" id="smtpFromTxt" type="text" class="textbox" value="<?php echo $_SLEX['smtp']['from'] ?>" /></td>
    <td class="tips">例如 admin@maiyun.net，必须正确，否则发件失败 </td>
  </tr>
</table>
<div class="controls">
  <a class="button" href="javascript:void(0);" onclick="$('#mainForm').trigger('submit');return false;">保存<i></i></a>　<a class="button" id="sendMailBtn" href="javascript:void(0);" onclick="return false;">发信测试<i></i></a>
</div>
</form>
<div id="sendTestWindow" class="windowE">
  <div class="windowContent">
    <table border="0" cellspacing="0" cellpadding="0" class="sTable">
      <tr>
        <td width="70" style="padding-top:0;">接收邮箱</td>
        <td style="padding-top:0;"><input name="toTxt" id="toTxt" type="text" style="width:180px;" value="@" class="textbox" /></td>
      </tr>
      <tr>
        <td width="70">邮件标题</td>
        <td><input name="titleTxt" id="titleTxt" type="text" style="width:180px;" class="textbox" /></td>
      </tr>
      <tr>
        <td width="70">邮件正文</td>
        <td><textarea name="htmlTxt" id="htmlTxt" style="width:180px;height:80px;resize:none;" class="textbox"></textarea></td>
      </tr>
    </table>
  </div>
  <div class="windowBottom"><a class="button" href="javascript:void(0);" onclick="return false;">发送<i></i></a>　<a class="button" href="javascript:void(0);" onclick="hideWindow();return false;">取消<i></i></a></div>
</div>
</body>
</html>