Location: PHPKode > projects > QuickTicket > quickticket/qti_adm_smtp.php
<?php

/**
* PHP versions 4 and 5
*
* LICENSE: This source file is subject to version 3.0 of the PHP license
* that is available through the world-wide-web at the following URI:
* http://www.php.net/license. If you did not receive a copy of
* the PHP License and are unable to obtain it through the web, please
* send a note to hide@address.com so we can mail you a copy immediately.
*
* @package    QuickTicket
* @author     Philippe Vandenberghe <hide@address.com>
* @copyright  2008-2012 The PHP Group
* @version    2.3 build:20091102
*/

session_start();
require_once('bin/qti_init.php');
if ( $oVIP->role!='A' ) die('Access is restricted to administrators only');

// INITIALISE

include('bin/qt_lib_smtp.php');

$oVIP->selfurl = 'qti_adm_smtp.php';
$oVIP->selfname = '<span class="upper">Info</span><br/>SMTP test';

if ( isset($_GET['h']) ) $_SESSION[QT]['smtp_host'] = strip_tags($_GET['h']);
if ( isset($_GET['u']) ) $_SESSION[QT]['smtp_username'] = strip_tags($_GET['u']);
if ( isset($_GET['p']) ) $_SESSION[QT]['smtp_password'] = strip_tags($_GET['p']);

// --------
// SUBMITTED
// --------

if ( isset($_POST['ok']) )
{
  // register value used
  $_SESSION[QT]['smtp_host'] = $_POST['smtphost'];
  $_SESSION[QT]['smtp_username'] = $_POST['smtpusr'];
  $_SESSION[QT]['smtp_password'] = $_POST['smtppwd'];
  if ( !QTismail($_POST['mailto']) ) die($L['Email'].' '.$L['E_invalid']);

  // send mail
  smtpmail($_POST['mailto'],$_POST['subject'],$_POST['message'],'From:'.$_SESSION[QT]['admin_email']);

  // exit
  $oVIP->exiturl = 'qti_adm_smtp.php';
  $oVIP->exitname = 'SMTP test';
  $oVIP->EndMessage(NULL,'Process completed...<br/><br/>If you have changed the smtp settings during the test, go to the Administration page and SAVE your new settings!','admin',0);
}

// --------
// HTML START
// --------

$bJava = false;

include('qti_adm_p_header.php');
include('qti_adm_p_title.php');

// CONTENT

echo '<form method="post" action="',$oVIP->selfurl,'">
<table class="data_o" cellspacing="0">
<tr class="data_o">
<td class="th_o th_o_all" style="width:200px;">SMTP Settings</td>
<td class="td_o" style="width:200px;">&nbsp;</td>
<td class="td_o">&nbsp;</td>
</tr>
';
echo '<tr class="data_o">
<td class="th_o th_o_first"><label for="smtphost">Smtp host</label></td>
<td class="td_o"><input type="text" id="smtphost" name="smtphost" size="30" maxlength="64" value="',$_SESSION[QT]['smtp_host'],'"/></td>
<td class="td_o">&nbsp;</td>
</tr>
';
echo '<tr class="data_o">
<td class="th_o th_o_first"><label for="smtpusr">Smtp username</label></td>
<td class="td_o"><input type="text" id="smtpusr" name="smtpusr" size="30" maxlength="64" value="',$_SESSION[QT]['smtp_username'],'"/></td>
<td class="td_o">&nbsp;</td>
</tr>
';
echo '<tr class="data_o">
<td class="th_o th_o_first"><label for="smtppwd">Smtp password</label></td>
<td class="td_o"><input type="text" id="smtppwd" name="smtppwd" size="30" maxlength="64" value="',$_SESSION[QT]['smtp_password'],'"/></td>
<td class="td_o">&nbsp;</td>
</tr>
';
echo '<tr class="data_o">
<td class="th_o th_o_all">',$L['Email'],'</td>
<td class="td_o">&nbsp;</td>
<td class="td_o">&nbsp;</td>
</tr>
';
echo '<tr class="data_o">
<td class="th_o th_o_first"><label for="mailto">SEND TO</label></td>
<td class="td_o"><input type="text" id="mailto" name="mailto" size="30" maxlength="64" value=""/></td>
<td class="td_o">&nbsp;</td>
</tr>
';
echo '<tr class="data_o">
<td class="th_o th_o_first"><label for="subject">Subject</label></td>
<td class="td_o"><input type="text" id="subject" name="subject" size="30" maxlength="64" value="Test smtp"/></td>
<td class="td_o">&nbsp;</td>
</tr>
';
echo '<tr class="data_o">
<td class="th_o th_o_first"><label for="message">Message</label></td>
<td class="td_o"><input type="text" id="message" name="message" size="30" maxlength="64" value="Test mail send by smtp server"/></td>
<td class="td_o">&nbsp;</td>
</tr>
';
echo '<tr class="data_o">
<td class="th_o th_o_first">&nbsp;</td>
<td class="td_o"><input type="submit" name="ok" value="',$L['Send'],'"/></td>
<td class="td_o">&nbsp;</td>
</tr>
</table>
</form><br/>
';

// HTML END

include('qti_adm_p_footer.php');

?>
Return current item: QuickTicket