* Refactory the email setting.

* Finish task#818.
This commit is contained in:
wangchunsheng
2012-06-21 12:25:25 +00:00
parent 73fb25c2bd
commit 90b50b3a4b
12 changed files with 418 additions and 309 deletions
+33 -13
View File
@@ -1,24 +1,44 @@
<?php
$config->mail->turnon = false; // trun on email feature or not.
$config->mail->fromAddress = ''; // The from address.
$config->mail->fromName = ''; // The from name.
$config->mail->mta = 'smtp'; // phpmail|sendmail|smtp|gmail
$config->mail->turnon = 0; // trun on email feature or not.
$config->mail->fromAddress = ''; // The from address.
$config->mail->fromName = 'zentao'; // The from name.
$config->mail->mta = 'smtp'; // smtp|phpmail.
/* SMTP settings. */
if($config->mail->mta == 'smtp')
{
$config->mail->smtp->debug = 0; // Debug level, 0,1,2.
$config->mail->smtp->auth = true; // Need auth or not.
$config->mail->smtp->host = ''; // The smtp server host address.
$config->mail->smtp->port = ''; // The smtp server host port.
$config->mail->smtp->host = 'localhost'; // The smtp server host address.
$config->mail->smtp->port = '25'; // The smtp server host port.
$config->mail->smtp->secure = ''; // The type to encode datas, 'ssl' or 'tls' allowed
$config->mail->smtp->username = ''; // The smtp user, may be a full email adress.
$config->mail->smtp->password = ''; // The smtp user's password.
}
/* Gmail setting. */
elseif($config->mail->mta == 'gmail')
{
$config->mail->gmail->debug = 0; // Debug level, 0,1,2.
$config->mail->gmail->username = ""; // GMAIL username
$config->mail->gmail->password = ""; // GMAIL password
}
$config->mail->provider['163.com']->host = 'smtp.163.com';
$config->mail->provider['yeah.net']->host = 'smtp.yeah.net';
$config->mail->provider['netease.com']->host = 'smtp.netease.com';
$config->mail->provider['126.com']->host = 'smtp.126.com';
$config->mail->provider['qiye.163.com']->host = 'smtp.qiye.163.com';
$config->mail->provider['sina.com']->host = 'smtp.sina.com';
$config->mail->provider['sina.cn']->host = 'smtp.sina.cn';
$config->mail->provider['vip.sina.com']->host = 'smtp.vip.sina.com';
$config->mail->provider['sina.net']->host = 'smtp.sina.net';
$config->mail->provider['sohu.com']->host = 'smtp.sohu.com';
$config->mail->provider['vip.sohu.com']->host = 'smtp.vip.sohu.com';
$config->mail->provider['21cn.com']->host = 'smtp.21cn.com';
$config->mail->provider['qq.com']->host = 'smtp.qq.com';
$config->mail->provider['gmail.com']->host = 'smtp.gmail.com';
$config->mail->provider['gmail.com']->secure = 'ssl';
$config->mail->provider['gmail.com']->port = '465';
$config->mail->provider['google.com'] = $config->mail->provider['gmail.com'];
$config->mail->provider['googlemail.com'] = $config->mail->provider['gmail.com'];
$config->mail->provider['263.net']->host = 'smtp.263.net';
$config->mail->provider['263xmail.com']->host = 'smtp.263xmail.com';
+95 -70
View File
@@ -11,15 +11,65 @@
*/
class mail extends control
{
public function index()
{
if($this->config->mail->turnon) $this->locate(inlink('edit'));
$this->locate(inlink('detect'));
}
/**
* Config email.
* Detect email config auto.
*
* @access public
* @return void
*/
public function set()
public function detect()
{
$this->view->mailConfig = $this->app->loadConfig('mail')->mail;
if($_POST)
{
$error = '';
if($this->post->fromAddress == false) $error = sprintf($this->lang->error->notempty, $this->lang->mail->fromAddress);
if(!validater::checkEmail($this->post->fromAddress)) $error .= '\n' . sprintf($this->lang->error->email, $this->lang->mail->fromAddress);
if($error) die(js::alert($error));
$mailConfig = $this->mail->autoDetect($this->post->fromAddress);
$mailConfig->fromAddress = $this->post->fromAddress;
$this->session->set('mailConfig', $mailConfig);
die(js::locate(inlink('edit'), 'parent'));
}
$this->view->header->title = $this->lang->mail->detect;
$this->view->position[] = html::a(inlink('index'), $this->lang->mail->common);
$this->view->position[] = $this->lang->mail->detect;
$this->view->fromAddress = $this->session->mailConfig ? $this->session->mailConfig->fromAddress : '';
$this->display();
}
/**
* Edit the mail config.
*
* @access public
* @return void
*/
public function edit()
{
$mailConfig = $this->session->mailConfig ? $this->session->mailConfig : $this->config->mail->smtp;
if(!isset($mailConfig->debug)) $mailConfig->debug = 1;
if(!isset($mailConfig->username)) $mailConfig->username = '';
if(!isset($mailConfig->password)) $mailConfig->password = '';
if(!isset($mailConfig->secure)) $mailConfig->secure = '';
if(!isset($mailConfig->fromName)) $mailConfig->fromName = 'zentao';
$this->view->header->title = $this->lang->mail->edit;
$this->view->position[] = html::a(inlink('index'), $this->lang->mail->common);
$this->view->position[] = $this->lang->mail->edit;
$this->view->mailConfig = $mailConfig;
$this->display();
}
@@ -33,81 +83,56 @@ class mail extends control
{
if(!empty($_POST))
{
if('gmail' == $this->post->mta)
{
$config = <<<EOT
<?php
\$config->mail->turnon = {$this->post->turnon};
\$config->mail->fromAddress = "{$this->post->fromAddress}";
\$config->mail->mta = "gmail";
\$config->mail->fromName = "{$this->post->fromName}";
\$config->mail->gmail->debug = {$this->post->gmailDebug};
\$config->mail->gmail->username = "{$this->post->gmailUsername}";
\$config->mail->gmail->password = "{$this->post->gmailPassword}";
EOT;
}
elseif('smtp' == $this->post->mta)
{
$position = strpos($this->post->fromAddress, '@');
if($this->post->smtpHost == '')
{
$host = 'smtp.' . substr($this->post->fromAddress, $position + 1);
}
else
{
$host = $this->post->smtpHost;
}
$config = <<<EOT
$mailConfig = <<<EOT
<?php
\$config->mail->turnon = {$this->post->turnon};
\$config->mail->mta = 'smtp';
\$config->mail->fromAddress = "{$this->post->fromAddress}";
\$config->mail->mta = "{$this->post->mta}";
\$config->mail->fromName = "{$this->post->fromName}";
\$config->mail->smtp->debug = {$this->post->smtpDebug};
\$config->mail->smtp->username = "{$this->post->smtpUsername}";
\$config->mail->smtp->password = "{$this->post->smtpPassword}";
\$config->mail->smtp->auth = {$this->post->smtpAuth};
\$config->mail->smtp->host = "$host";
\$config->mail->smtp->secure = "{$this->post->smtpSecure}";
\$config->mail->smtp->port = "{$this->post->smtpPort}";
\$config->mail->smtp->host = "{$this->post->host}";
\$config->mail->smtp->port = "{$this->post->port}";
\$config->mail->smtp->auth = {$this->post->auth};
\$config->mail->smtp->username = "{$this->post->username}";
\$config->mail->smtp->password = "{$this->post->password}";
\$config->mail->smtp->secure = "{$this->post->secure}";
\$config->mail->smtp->debug = {$this->post->debug};
EOT;
}
elseif('phpmail' == $this->post->mta or 'sendmail' == $this->post->mta)
{
$config = <<<EOT
<?php
\$config->mail->turnon = {$this->post->turnon};
\$config->mail->fromAddress = "{$this->post->fromAddress}";
\$config->mail->mta = "{$this->post->mta}";
\$config->mail->fromName = "{$this->post->fromName}";
EOT;
}
/* Output config to the extconfig file of mail */
$configPath = $this->app->getModuleExtPath('mail', 'config');
if(is_writable($configPath))
{
if(file_put_contents($configPath . 'zzzemail.php', $config))
{
/* Send test mail */
$this->mail->send($this->app->user->account, $this->lang->mail->subject, $this->lang->mail->content,"", true);
if($this->mail->isError()) echo js::error($this->mail->getError());
echo js::confirm($this->lang->mail->confirmSave,$this->createLink('mail', 'set'));
}
else
{
$this->view->config = $config;
$this->view->configPath = $configPath;
$this->display();
}
}
else
{
$this->view->config = $config;
$this->view->configPath = $configPath;
$this->display();
}
$configFile = $configPath . 'zzzemail.php';
$saved = false;
if(is_file($configFile) and is_writable($configFile)) $saved = file_put_contents($configFile, $mailConfig);
if(!is_file($configFile) and is_writable($configPath)) $saved = file_put_contents($configFile, $mailConfig);
$this->view->header->title = $this->lang->mail->save;
$this->view->position[] = html::a(inlink('index'), $this->lang->mail->common);
$this->view->position[] = $this->lang->mail->save;
$this->view->mailConfig = $mailConfig;
$this->view->configPath = $configPath;
$this->view->configFile = $configFile;
$this->view->saved = $saved;
$this->display();
}
}
/**
* Send test email.
*
* @access public
* @return void
*/
public function test()
{
if($_POST)
{
$this->mail->send($this->post->to, $this->lang->mail->subject, $this->lang->mail->content,"", true);
if($this->mail->isError()) die(js::error($this->mail->getError()));
die(js::alert($this->lang->mail->successSended));
}
$this->view->users = $this->dao->select('account, CONCAT(realname, " ", email) AS email' )->from(TABLE_USER)->where('email')->ne('')->orderBy('account')->fetchPairs();
$this->display();
}
}
+4
View File
@@ -0,0 +1,4 @@
$(document).ready()
{
$('#fromAddress').focus();
}
+4
View File
@@ -0,0 +1,4 @@
$(document).ready()
{
$('#password').focus();
}
-57
View File
@@ -1,57 +0,0 @@
function setMtaType(type)
{
if(type == 'gmail')
{
$('#gmailUsername').show();
$('#gmailPassword').show();
$('#gmailDebug').show();
$('#smtpDebug').hide();
$('#smtpUsername').hide();
$('#smtpPassword').hide();
$('#smtpHost').hide();
$('#smtpAuth').hide();
$('#smtpSecure').hide();
$('#smtpPort').hide();
}
else if(type == 'smtp')
{
$('#gmailUsername').hide();
$('#gmailPassword').hide();
$('#gmailDebug').hide();
$('#smtpDebug').show();
$('#smtpUsername').show();
$('#smtpPassword').show();
$('#smtpHost').show();
$('#smtpAuth').show();
$('#smtpSecure').show();
$('#smtpPort').show();
}
else if(type == 'phpmail' || type == 'sendmail')
{
$('#gmailUsername').hide();
$('#gmailPassword').hide();
$('#gmailDebug').hide();
$('#smtpDebug').hide();
$('#smtpUsername').hide();
$('#smtpPassword').hide();
$('#smtpHost').hide();
$('#smtpAuth').hide();
$('#smtpSecure').hide();
$('#smtpPort').hide();
}
}
function setVerificationType(type)
{
if(type == 'true')
{
$('#smtpUsername').show();
$('#smtpPassword').show();
}
else if(type == 'false')
{
$('#smtpUsername').hide();
$('#smtpPassword').hide();
}
}
type = document.getElementById("mta")
setMtaType(type.value);
+34 -46
View File
@@ -1,53 +1,41 @@
<?php
$lang->mail->setParam = '请设置下面的配置参数';
$lang->mail->common = '发信配置';
$lang->mail->index = '首页';
$lang->mail->detect = '检测';
$lang->mail->edit = '编辑配置';
$lang->mail->save = '保存配置';
$lang->mail->test = '测试发信';
$lang->mail->turnon = '是否打开发信功能';
$lang->mail->fromAddress = '发信人邮箱';
$lang->mail->fromName = '发信人名称';
$lang->mail->mta = '请选择发信方式';
$lang->mail->debugExample = '0表示关闭调试信息,1和2表示打开调试信息,但2比1调试信息显示更详细';
$lang->mail->turnon = '是否打开';
$lang->mail->fromAddress = '发信邮箱';
$lang->mail->fromName = '发信人';
$lang->mail->mta = '发信方式';
$lang->mail->host = 'smtp服务器';
$lang->mail->port = 'smtp端口号';
$lang->mail->auth = '是否需要验证';
$lang->mail->username = 'smtp帐号';
$lang->mail->password = 'smtp密码';
$lang->mail->secure = '是否加密';
$lang->mail->debug = '调试级别';
$lang->mail->mtaList['gmail'] = 'Gmail服务器方式';
$lang->mail->mtaList['smtp'] = 'SMTP服务器方式';
$lang->mail->mtaList['phpmail'] = 'PHP内置mail函数';
$lang->mail->mtaList['sendmail'] = '本机sendmail';
$lang->mail->turnonList[1] = '打开';
$lang->mail->turnonList[0] = '关闭';
/* Trun on email feature or not */
$lang->mail->turnonList['true'] = '打开';
$lang->mail->turnonList['false'] = '关闭';
$lang->mail->debugList[0] = '关闭';
$lang->mail->debugList[1] = '一般';
$lang->mail->debugList[2] = '较高';
$lang->mail->debugList[2] = '2';
$lang->mail->debugList[0] = '0';
$lang->mail->debugList[1] = '1';
$lang->mail->authList[1] = '需要';
$lang->mail->authList[0] = '不需要';
$lang->mail->smtp->authList['true'] = '是';
$lang->mail->smtp->authList['false'] = '否';
$lang->mail->secureList[''] = '不加密';
$lang->mail->secureList['ssl'] = 'ssl';
$lang->mail->secureList['tls'] = 'tls';
$lang->mail->smtp->secureList[''] = '不加密';
$lang->mail->smtp->secureList['ssl'] = 'ssl';
$lang->mail->smtp->secureList['tls'] = 'tls';
/* Set SMTP */
$lang->mail->smtp->fromName = '发信人姓名';
$lang->mail->smtp->auth = '是否需要验证';
$lang->mail->smtp->debug = '请选择调试等级';
$lang->mail->smtp->secure = '请选择SMTP加密方式';
$lang->mail->smtp->host = '请输入HOST';
$lang->mail->smtp->hostInfo = '如不是特殊HOST,可不填写,系统会自动生成';
$lang->mail->smtp->username = '发信邮箱用户名';
$lang->mail->smtp->password = '请输入密码';
$lang->mail->smtp->port = '请输入端口号';
$lang->mail->smtp->portInfo = 'ssl加密方式默认端口号为465,tls加密方式默认端口号为587,不加密端口号一般为空';
/* Set gmail */
$lang->mail->gmail->username = '请输入发信邮箱用户名';
$lang->mail->gmail->password = '请输入发信邮箱密码';
$lang->mail->gmail->debug = '请选择调试等级';
$lang->mail->confirmSave = '保存成功, 请到您的邮箱中查看测试邮件是否发送成功。';
$lang->mail->subject = '测试邮件';
$lang->mail->content = '邮箱设置成功';
/* Save config information */
$lang->mail->configInfo = '配置信息';
$lang->mail->saveConfig = '请将该配置信息保存到: ';
$lang->mail->createFile = '如果zzzemail.php文件不存在,请手动创建该文件,将以上配置保存即可。';
$lang->mail->inputFromEmail = '请输入发信邮箱:';
$lang->mail->nextStep = '下一步';
$lang->mail->successSaved = '配置信息已经成功保存到:<span class="red">%s</span>';
$lang->mail->saveManual = '请将该配置信息保存到:<span class="red">%s</span>';
$lang->mail->subject = '测试邮件';
$lang->mail->content = '邮箱设置成功';
$lang->mail->successSended = '成功发送!';
+117
View File
@@ -25,6 +25,123 @@ class mailModel extends model
$this->setMTA();
}
/**
* Auto detect email config.
*
* @param int $email
* @access public
* @return void
*/
public function autoDetect($email)
{
list($username, $domain) = explode('@', $email);
$domain = strtolower($domain);
/* 1. try get config from providers. */
if(isset($this->config->mail->provider[$domain]))
{
$config = $this->config->mail->provider[$domain];
$config->mta = 'smtp';
$config->username = $username;
$config->auth = 1;
if(!isset($config->port)) $config->port = 25;
if(!isset($config->secure)) $config->secure = '';
return $config;
}
/* 2. try get config by MX record. */
$config = $this->getConfigByMXRR($domain);
if($config)
{
$config->username = $email;
return $config;
}
/* 3. try 25 and 465 port. */
$smtpHost = 'smtp.' . $domain;
$config->mta = 'smtp';
$config->username = $username;
$config->host = $smtpHost;
$config->auth = 1;
if($this->connectSMTP($smtpHost, 25))
{
$config->port = 25;
$config->secure = '';
return $config;
}
elseif($this->connectSMTP($smtpHost, 465))
{
$config->port = 465;
$config->secure = 'ssl';
return $config;
}
}
/**
* Get config by MXRR.
*
* @param int $domain
* @access public
* @return void
*/
public function getConfigByMXRR($domain)
{
/* Try to get mx record, under linux, use getmxrr() directly, windows use nslookup. */
if(function_exists('getmxrr'))
{
getmxrr($domain, $smtpHosts);
}
elseif(strpos(PHP_OS, 'WIN') !== false)
{
$smtpHosts = array();
$result = `nslookup -q=mx {$domain} 2>nul`;
$lines = explode("\n", $result);
foreach($lines as $line)
{
if(stripos($line, 'exchanger')) $smtpHosts[] = trim(substr($line, strrpos($line, '=') + 1));
}
}
/* Cycle the smtpHosts and try to find it's config from the provider config. */
foreach($smtpHosts as $smtpHost)
{
/* Get the domain name from the hosts, for example: imxbiz1.qq.com get qq.com. */
$smtpDomain = explode('.', $smtpHost);
array_shift($smtpDomain);
$smtpDomain = strtolower(implode('.', $smtpDomain));
/* If there's config in the provider config, return it. */
if(isset($this->config->mail->provider[$smtpDomain]))
{
$config = $this->config->mail->provider[$smtpDomain];
$config->mta = 'smtp';
$config->auth = 1;
if(!isset($config->port)) $config->port = 25;
return $config;
}
}
return false;
}
/**
* Try to connect SMTP server.
*
* @param int $host
* @param int $port
* @access public
* @return void
*/
public function connectSMTP($host, $port)
{
ini_set('default_socket_timeout', 1);
$connection = @fsockopen($host, $port);
if(!$connection) return false;
fclose($connection);
return true;
}
/**
* Set MTA.
*
+20
View File
@@ -0,0 +1,20 @@
<?php
/**
* The detect view file of mail module of ZenTaoPMS.
*
* @copyright Copyright 2009-2012 QingDao Nature Easy Soft Network Technology Co,LTD (www.cnezsoft.com)
* @license LGPL (http://www.gnu.org/licenses/lgpl.html)
* @author Chunsheng Wang <wwccss@cnezsoft.com>
* @package mail
* @version $Id$
* @link http://www.zentao.net
*/
include '../../common/view/header.html.php';
?>
<form method='post' target='hiddenwin'>
<table class='table-4' align='center'>
<caption><?php echo $lang->mail->inputFromEmail; ?></caption>
<tr><td class='a-center'><?php echo html::input('fromAddress', $fromAddress, 'class=text-3') . html::submitButton($lang->mail->nextStep);?></td></tr>
</table>
</form>
<?php include '../../common/view/footer.html.php';?>
+68
View File
@@ -0,0 +1,68 @@
<?php
/**
* The edit view file of mail module of ZenTaoPMS.
*
* @copyright Copyright 2009-2012 QingDao Nature Easy Soft Network Technology Co,LTD (www.cnezsoft.com)
* @license LGPL (http://www.gnu.org/licenses/lgpl.html)
* @author Chunsheng Wang <wwccss@cnezsoft.com>
* @package mail
* @version $Id$
* @link http://www.zentao.net
*/
include '../../common/view/header.html.php';
?>
<form method='post' action='<?php echo inlink('save');?>'>
<table align='center' class='table-4'>
<caption><?php echo $lang->mail->edit;?></caption>
<tr>
<th class='rowhead'><?php echo $lang->mail->turnon; ?></th>
<td><?php echo html::radio('turnon', $lang->mail->turnonList, 1);?></td>
</tr>
<tr>
<th class='rowhead'><?php echo $lang->mail->fromAddress; ?></th>
<td><?php echo html::input('fromAddress', $mailConfig->fromAddress, 'class=text-3');?></td>
</tr>
<tr>
<th class='rowhead'><?php echo $lang->mail->fromName; ?></th>
<td><?php echo html::input('fromName', $mailConfig->fromName, 'class=text-3');?></td>
</tr>
<tr>
<th class='rowhead'><?php echo $lang->mail->host; ?></th>
<td><?php echo html::input('host', $mailConfig->host, 'class=text-3');?></td>
</tr>
<tr>
<th class='rowhead'><?php echo $lang->mail->port; ?></th>
<td><?php echo html::input('port', $mailConfig->port, 'class=text-3');?></td>
</tr>
<tr>
<th class='rowhead'><?php echo $lang->mail->auth; ?></th>
<td><?php echo html::radio('auth', $lang->mail->authList, $mailConfig->auth, 'onchange=setAuth(this.value)'); ?></td>
</tr>
<tr>
<th class='rowhead'><?php echo $lang->mail->username; ?></th>
<td><?php echo html::input('username', $mailConfig->username, 'class=text-3') ?></td>
</tr>
<tr>
<th class='rowhead'><?php echo $lang->mail->password; ?></th>
<td><?php echo html::password('password', $mailConfig->password, 'class="text-3" autocomplete="off"') ?></td>
</tr>
<tr>
<th class='rowhead'><?php echo $lang->mail->secure; ?></th>
<td><?php echo html::radio('secure', $lang->mail->secureList, $mailConfig->secure); ?></td>
</tr>
<tr>
<th class='rowhead'><?php echo $lang->mail->debug; ?></th>
<td><?php echo html::radio('debug', $lang->mail->debugList, $mailConfig->debug);?></td>
</tr>
<tr>
<td colspan='2' class='a-center'>
<?php
echo html::submitButton();
if($this->config->mail->turnon) echo html::linkButton($lang->mail->test, inlink('test'));
?>
</td>
</tr>
</table>
</form>
<?php include '../../common/view/footer.html.php';?>
+15 -13
View File
@@ -1,25 +1,27 @@
<?php
/**
* The config email view file of mail module of ZenTaoPMS.
* The save view file of mail module of ZenTaoPMS.
*
* @copyright Copyright 2009-2012 QingDao Nature Easy Soft Network Technology Co,LTD (www.cnezsoft.com)
* @license LGPL (http://www.gnu.org/licenses/lgpl.html)
* @author Yangyang Shi <shiyangyang@cnezsoft.com>
* @author Chunsheng Wang <wwccss@cnezsoft.com>
* @package mail
* @version $Id$
* @link http://www.zentao.net
*/
include '../../common/view/header.html.php';
?>
<table class='table-6' align='center'>
<caption><?php echo $lang->mail->configInfo ?></caption>
<tr>
<td><? echo html::textArea('', $config, "rows='15' class='area-1 f-12px'");?>
</tr>
<tr>
<td><?php echo $lang->mail->saveConfig . $configPath . 'zzzemail.php' ?></td>
</tr>
<tr>
<td><?php echo $lang->mail->createFile ?></td>
</tr>
<table class='table-5' align='center'>
<caption><?php echo $lang->mail->save ?></caption>
<tr>
<td>
<?php
echo html::textArea('', $mailConfig, "rows='12' class='area-1'") . '<br /><br />';
if($saved) printf($lang->mail->successSaved, $configFile);
if($saved) echo html::linkButton($lang->mail->test, inlink('test'));
if(!$saved) printf($lang->mail->saveManual, $configFile);
?>
</td>
</tr>
</table>
<?php include '../../common/view/footer.html.php';?>
-110
View File
@@ -1,110 +0,0 @@
<?php
/**
* The config email view file of mail module of ZenTaoPMS.
*
* @copyright Copyright 2009-2012 QingDao Nature Easy Soft Network Technology Co,LTD (www.cnezsoft.com)
* @license LGPL (http://www.gnu.org/licenses/lgpl.html)
* @author Yangyang Shi <shiyangyang@cnezsoft.com>
* @package mail
* @version $Id$
* @link http://www.zentao.net
*/
include '../../common/view/header.html.php';
include '../../common/view/tablesorter.html.php';?>
<?php
$turnon = 'false';
$mta = 'smtp';
$gmailUsername = '';
$gmailPassword = '';
$smtpUsername = '';
$smtpPassword = '';
$smtpHost = '';
$smtpSecure = '';
$smtpAuth = '';
$smtpPort = '';
if($mailConfig->turnon == 1) $turnon = 'ture';
if(!empty($mailConfig->mta)) $mta = $mailConfig->mta;
if(!empty($mailConfig->gmail->username)) $gmailUsername = $mailConfig->gmail->username;
if(!empty($mailConfig->gmail->password)) $gmailPassword = $mailConfig->gmail->password;
if(!empty($mailConfig->smtp->username)) $smtpUsername = $mailConfig->smtp->username;
if(!empty($mailConfig->smtp->password)) $smtpPassword = $mailConfig->smtp->password;
if(!empty($mailConfig->smtp->host)) $smtpHost = $mailConfig->smtp->host;
if(!empty($mailConfig->smtp->secure)) $smtpSecure = $mailConfig->smtp->secure;
if(!empty($mailConfig->smtp->auth)) $smtpAuth = $mailConfig->smtp->auth;
if(!empty($mailConfig->smtp->port)) $smtpPort = $mailConfig->smtp->port;
?>
<form method='post' enctype='multipart/form-data' action='<?php echo inlink('save');?>'>
<table align='center' class='table-1'>
<caption><?php echo $lang->mail->setParam; ?></caption>
<tr>
<th class='rowhead w-200px'><?php echo $lang->mail->turnon; ?></th>
<td><?php echo html::select('turnon', $lang->mail->turnonList, $turnon, 'class=select-3'); ?></td>
</tr>
<tr>
<th class='rowhead'><?php echo $lang->mail->mta; ?></th>
<td><?php echo html::select('mta', $lang->mail->mtaList, $mta, 'class=select-3 onchange=setMtaType(this.value)'); ?></td>
</tr>
<tr>
<th class='rowhead'><?php echo $lang->mail->fromAddress; ?></th>
<td><?php echo html::input('fromAddress', $mailConfig->fromAddress, 'class=text-3') ?></td>
</tr>
<tr>
<th class='rowhead'><?php echo $lang->mail->fromName; ?></th>
<td><?php echo html::input('fromName', $mailConfig->fromName, 'class=text-3') ?></td>
</tr>
<tr id='gmailDebug' class='hidden'>
<th class='rowhead'><?php echo $lang->mail->gmail->debug; ?></th>
<td>
<?php
echo html::select('gmailDebug', $lang->mail->debugList, isset($mailConfig->gmail->debug) ? $mailConfig->gmail->debug : '', 'class=select-3');
echo $lang->mail->debugExample;
?>
</td>
</tr>
<tr id='gmailUsername' class='hidden'>
<th class='rowhead'><?php echo $lang->mail->gmail->username; ?></th>
<td><?php echo html::input('gmailUsername', $gmailUsername, 'class=text-3') ?></td>
</tr>
<tr id='gmailPassword' class='hidden'>
<th class='rowhead'><?php echo $lang->mail->gmail->password; ?></th>
<td><?php echo html::password('gmailPassword', $gmailPassword, 'class="text-3" autocomplete="off"') ?></td>
</tr>
<tr id='smtpHost' class='hidden'>
<th class='rowhead'><?php echo $lang->mail->smtp->host; ?></th>
<td><?php echo html::input('smtpHost', $smtpHost, 'class=text-3'); echo $lang->mail->smtp->hostInfo;?></td>
</tr>
<tr id='smtpDebug' class='hidden'>
<th class='rowhead'><?php echo $lang->mail->smtp->debug; ?></th>
<td>
<?php
echo html::select('smtpDebug', $lang->mail->debugList, isset($mailConfig->smtp->debug) ? $mailConfig->smtp->debug : '', 'class=select-3');
echo $lang->mail->debugExample;
?>
</td>
</tr>
<tr id='smtpAuth' class='hidden'>
<th class='rowhead'><?php echo $lang->mail->smtp->auth; ?></th>
<td><?php echo html::select('smtpAuth', $lang->mail->smtp->authList, $smtpAuth, 'class=select-3 onchange=setVerificationType(this.value)'); ?></td>
</tr>
<tr id='smtpUsername' class='hidden'>
<th class='rowhead'><?php echo $lang->mail->smtp->username; ?></th>
<td><?php echo html::input('smtpUsername', $smtpUsername, 'class=text-3') ?></td>
</tr>
<tr id='smtpPassword' class='hidden'>
<th class='rowhead'><?php echo $lang->mail->smtp->password; ?></th>
<td><?php echo html::password('smtpPassword', $smtpPassword, 'class="text-3" autocomplete="off"') ?></td>
</tr>
<tr id='smtpSecure' class='hidden'>
<th class='rowhead'><?php echo $lang->mail->smtp->secure; ?></th>
<td><?php echo html::select('smtpSecure', $lang->mail->smtp->secureList, $smtpSecure, 'class=select-3'); ?></td>
</tr>
<tr id='smtpPort' class='hidden'>
<th class='rowhead'><?php echo $lang->mail->smtp->port; ?></th>
<td><?php echo html::input('smtpPort', $smtpPort, 'class=text-3'); echo $lang->mail->smtp->portInfo ?></td>
</tr>
<tr>
<td colspan='2' class='a-center'><?php echo html::submitButton();?></td>
</tr>
</table>
</form>
<?php include '../../common/view/footer.html.php';?>
+28
View File
@@ -0,0 +1,28 @@
<?php
/**
* The test view file of mail module of ZenTaoPMS.
*
* @copyright Copyright 2009-2012 QingDao Nature Easy Soft Network Technology Co,LTD (www.cnezsoft.com)
* @license LGPL (http://www.gnu.org/licenses/lgpl.html)
* @author Chunsheng Wang <wwccss@cnezsoft.com>
* @package mail
* @version $Id$
* @link http://www.zentao.net
*/
include '../../common/view/header.html.php';
?>
<form method='post' target='hiddenwin'>
<table class='table-4' align='center'>
<caption><?php echo $lang->mail->test; ?></caption>
<tr>
<td class='a-center'>
<?php
echo html::select('to', $users, $app->user->account, 'class=text-3');
echo html::submitButton($lang->mail->test);
echo html::linkButton($lang->mail->edit, $this->inLink('edit'));
?>
</td>
</tr>
</table>
</form>
<?php include '../../common/view/footer.html.php';?>