Location: PHPKode > projects > QuickTalk Forum > quicktalk/qtf_ext_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    QuickTalk
* @author     Philippe Vandenberghe <hide@address.com>
* @copyright  2008-2012 The PHP Group
* @version    2.5 build:20100924
*/

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

// INITIALISE

include('bin/qt_lib_smtp.php');

$oVIP->selfurl = 'qtf_ext_smtp.php';
$oVIP->selfname = 'SMTP test';

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

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

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

  // send mail
  QTmail($_POST['mailto'],$_POST['subject'],$_POST['message'],'iso-8859-1','1');

  // exit
  $oVIP->exiturl = 'qtf_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
// --------

include('qtf_adm_p_header.php');

// CONTENT

echo '<br/>
<form method="post" action="',Href(),'">
<table class="data_o" cellspacing="0" summary="smtp test">
<tr class="data_o">
<td class="colhd colhdgroup" colspan="2">SMTP Settings</td>
</tr>
';
echo '<tr class="data_o">
<td class="colhd colhdfirst" style="width:200px;"><label for="smtphost">Smtp host</label></td>
<td class="colct"><input type="text" id="smtphost" name="smtphost" size="30" maxlength="64" value="',$_SESSION[QT]['smtp_host'],'"/></td>
</tr>
';
echo '<tr class="data_o">
<td class="colhd colhdfirst"><label for="smtphost">Port</label></td>
<td class="colct">
<input type="text" id="smtpport" name="smtpport" size="5" maxlength="6" value="',(isset($_SESSION[QT]['smtp_port']) ? $_SESSION[QT]['smtp_port'] : '25'),'"/>
</td>
</tr>
';
echo '<tr class="data_o">
<td class="colhd colhdfirst"><label for="smtpusr">Smtp username</label></td>
<td class="colct"><input type="text" id="smtpusr" name="smtpusr" size="30" maxlength="64" value="',$_SESSION[QT]['smtp_username'],'"/></td>
</tr>
';
echo '<tr class="data_o">
<td class="colhd colhdfirst"><label for="smtppwd">Smtp password</label></td>
<td class="colct"><input type="text" id="smtppwd" name="smtppwd" size="30" maxlength="64" value="',$_SESSION[QT]['smtp_password'],'"/></td>
</tr>
';
echo '<tr class="data_o">
<td class="colhd colhdgroup" colspan="2">',$L['Email'],'</td>
</tr>
';
echo '<tr class="data_o">
<td class="colhd colhdfirst"><label for="mailto">SEND TO</label></td>
<td class="colct"><input type="text" id="mailto" name="mailto" size="30" maxlength="64" value=""/></td>
</tr>
';
echo '<tr class="data_o">
<td class="colhd colhdfirst">From</td>
<td class="colct">',$_SESSION[QT]['admin_email'],'</td>
</tr>
';
echo '<tr class="data_o">
<td class="colhd colhdfirst"><label for="subject">Subject</label></td>
<td class="colct"><input type="text" id="subject" name="subject" size="30" maxlength="64" value="Test smtp"/></td>
</tr>
';
echo '<tr class="data_o">
<td class="colhd colhdfirst"><label for="message">Message</label></td>
<td class="colct"><input type="text" id="message" name="message" size="30" maxlength="64" value="Test mail send by smtp server"/></td>
</tr>
';
echo '<tr class="data_o">
<td class="colhd colhdfirst">&nbsp;</td>
<td class="colct"><input type="submit" name="ok" value="',$L['Send'],'"/></td>
</tr>
</table>
</form>
';

echo '<br/>
<table class="hidden" cellspacing="0"><tr class="hidden" summary="smtp test">
<td class="hidden" style="width:210px">&nbsp;</td>
<td class="hidden">
<div class="scrollmessage">
<h2>Setting examples</h2>
<p class="bold">Example for gmail</p>
<p>
Host <span style="color:#4444ff">tls://smtp.gmail.com</span><br/>
Port <span style="color:#4444ff">587</span><br/>
Username <span style="color:#4444ff">hide@address.com</span><br/>
Password <span style="color:#4444ff">your google account password</span><br/>
<br/>
<span class="small">Note: using ssl or tls requires that your webhost opens these transport sockets in the php configuration. When this is not possible or if the test failled, you can use standard mail function (in the administration page Site & contact, don\'t use external smtp server).</span>
</p>
';
echo '<p class="bold">Example for pop3 instead of smtp</p>
<p>
Host <span style="color:#4444ff">pop3.yourdomain.com</span><br/>
Port <span style="color:#4444ff">110</span><br/>
Username <span style="color:#4444ff">your username</span><br/>
Password <span style="color:#4444ff">your password</span><br/>
</p>
</div>
</td>
</tr>
</table>
';

// HTML END

include('qtf_adm_p_footer.php');

?>
Return current item: QuickTalk Forum