Changeset 1142 in subversion


Ignore:
Timestamp:
Feb 26, 2008 1:08:19 PM (5 years ago)
Author:
thomasb
Message:

Add SMTP test to installer script

Location:
trunk/roundcubemail/installer
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/roundcubemail/installer/config.php

    r1141 r1142  
    66require_once 'include/rcube_html.inc'; 
    77 
     8$RCI->load_config(); 
    89$RCI->load_defaults(); 
    910 
     
    168169<?php 
    169170 
     171require_once 'DB.php'; 
     172 
    170173$supported_dbs = array('MySQL' => 'mysql', 'MySQLi' => 'mysqli', 
    171174    'PgSQL' => 'pgsql', 'SQLite' => 'sqlite'); 
     
    183186$input_dbpass = new textfield(array('name' => '_dbpass', 'size' => 20, 'id' => "cfgdbpass")); 
    184187 
    185 $dsnw = parse_url($RCI->getprop('db_dsnw')); 
    186  
    187 echo $select_dbtype->show($_POST['_dbtype'] ? $_POST['_dbtype'] : $dsnw['scheme']); 
     188$dsnw = DB::parseDSN($RCI->getprop('db_dsnw')); 
     189 
     190echo $select_dbtype->show($_POST['_dbtype'] ? $_POST['_dbtype'] : $dsnw['phptype']); 
    188191echo '<label for="cfgdbtype">Database type</label><br />'; 
    189 echo $input_dbhost->show($_POST['_dbhost'] ? $_POST['_dbhost'] : $dsnw['host']); 
     192echo $input_dbhost->show($_POST['_dbhost'] ? $_POST['_dbhost'] : $dsnw['hostspec']); 
    190193echo '<label for="cfgdbhost">Database server</label><br />'; 
    191 echo $input_dbname->show($_POST['_dbname'] ? $_POST['_dbname'] : preg_replace('/^\//', '', $dsnw['path'])); 
     194echo $input_dbname->show($_POST['_dbname'] ? $_POST['_dbname'] : $dsnw['database']); 
    192195echo '<label for="cfgdbname">Database name</label><br />'; 
    193 echo $input_dbuser->show($_POST['_dbuser'] ? $_POST['_dbuser'] : $dsnw['user']); 
     196echo $input_dbuser->show($_POST['_dbuser'] ? $_POST['_dbuser'] : $dsnw['username']); 
    194197echo '<label for="cfgdbuser">Database user name (needs write permissions)</label><br />'; 
    195 echo $input_dbpass->show($_POST['_dbpass'] ? $_POST['_dbpass'] : $dsnw['pass']); 
     198echo $input_dbpass->show($_POST['_dbpass'] ? $_POST['_dbpass'] : $dsnw['password']); 
    196199echo '<label for="cfgdbpass">Database password</label><br />'; 
    197200 
  • trunk/roundcubemail/installer/index.php

    r1139 r1142  
    6565 
    6666<div id="footer"> 
    67   Installer by the RoundCube Dev Team. Copyright &copy; 2008 - Published under the GNU Public License 
     67  Installer by the RoundCube Dev Team. Copyright &copy; 2008 - Published under the GNU Public License;&nbsp; 
     68  Icons by <a href="http://famfamfam.com">famfamfam</a> 
    6869</div> 
    6970</body> 
  • trunk/roundcubemail/installer/rcube_install.php

    r1141 r1142  
    2828  var $config = array(); 
    2929  var $last_error = null; 
     30  var $email_pattern = '([a-z0-9][a-z0-9\-\.\+\_]*@[a-z0-9]([a-z0-9\-][.]?)*[a-z0-9])'; 
    3031   
    3132  /** 
     
    8990   * 
    9091   * @param string Property name 
     92   * @param string Default value 
    9193   * @return string The property value 
    9294   */ 
    93   function getprop($name) 
     95  function getprop($name, $default = null) 
    9496  { 
    9597    $value = isset($_REQUEST["_$name"]) ? $_REQUEST["_$name"] : $this->config[$name]; 
     
    98100      $value = self::random_key(24); 
    99101     
    100     return $value; 
     102    return $value !== null ? $value : $default; 
    101103  } 
    102104   
  • trunk/roundcubemail/installer/styles.css

    r1141 r1142  
    138138} 
    139139 
    140 label { 
     140dd label { 
    141141  padding-left: 0.5em; 
    142142} 
  • trunk/roundcubemail/installer/test.php

    r1141 r1142  
    124124?> 
    125125 
    126 <p>[@todo Add tests for IMAP and SMTP settings]</p> 
     126<h3>Test SMTP settings</h3> 
     127 
     128<p> 
     129Server: <?php echo $RCI->getprop('smtp_server', 'PHP mail()'); ?><br /> 
     130Port: <?php echo $RCI->getprop('smtp_port'); ?><br /> 
     131User: <?php echo $RCI->getprop('smtp_user', '(none)'); ?><br /> 
     132Password: <?php echo $RCI->getprop('smtp_pass', '(none)'); ?><br /> 
     133</p> 
     134 
     135<?php 
     136 
     137if (isset($_POST['sendmail']) && !empty($_POST['_from']) && !empty($_POST['_to'])) { 
     138   
     139  require_once 'lib/rc_mail_mime.inc'; 
     140  require_once 'include/rcube_smtp.inc'; 
     141   
     142  echo '<p>Trying to send email...<br />'; 
     143   
     144  if (preg_match('/^' . $RCI->email_pattern . '$/i', trim($_POST['_from'])) && 
     145      preg_match('/^' . $RCI->email_pattern . '$/i', trim($_POST['_to']))) { 
     146   
     147    $recipients = trim($_POST['_to']); 
     148 
     149    $headers = array( 
     150      'From' => trim($_POST['_from']), 
     151      'To'  => $recipients, 
     152      'Subject' => 'Test message from RoundCube', 
     153    ); 
     154 
     155    $body = 'This is a test to confirm that RoundCube can send email.'; 
     156 
     157    $mail_object  = new rc_mail_mime(); 
     158    $send_headers = $mail_object->headers($headers); 
     159 
     160    $smtp_response = array(); 
     161    $status = smtp_mail($headers['From'], $recipients, 
     162        ($foo = $mail_object->txtHeaders($send_headers)), 
     163        $body, $smtp_response); 
     164 
     165    if ($status) { 
     166        $RCI->pass('SMTP send'); 
     167    } 
     168    else { 
     169        $RCI->fail('SMTP send', join('; ', $smtp_response)); 
     170    } 
     171  } 
     172  else { 
     173    $RCI->fail('SMTP send', 'Invalid sender or recipient'); 
     174  } 
     175} 
     176 
     177echo '</p>'; 
     178 
     179?> 
     180 
     181<table> 
     182<tbody> 
     183  <tr><td><label for="sendmailfrom">Sender</label></td><td><input type="text" name="_from" value="" id="sendmailfrom" /></td></tr> 
     184  <tr><td><label for="sendmailto">Recipient</label></td><td><input type="text" name="_to" value="" id="sendmailto" /></td></tr> 
     185</tbody> 
     186</table> 
     187 
     188<p><input type="submit" name="sendmail" value="Send test mail" /></p> 
     189 
     190 
     191<p>[@todo Add tests for IMAP settings]</p> 
    127192 
    128193</form> 
Note: See TracChangeset for help on using the changeset viewer.