Commit 18062f22 authored by Ruslan Kabalin's avatar Ruslan Kabalin
Browse files

Add an interface for email settings configuration.



Change-Id: I4b6646fd89e410e71d75c0bbd6b0e40caa30ceb5
Signed-off-by: default avatarRuslan Kabalin <ruslan.kabalin@luns.net.uk>
parent 9dc9df63
......@@ -377,6 +377,56 @@ $siteoptionform = array(
),
),
),
'emailsettings' => array(
'type' => 'fieldset',
'collapsible' => true,
'collapsed' => true,
'legend' => get_string('emailsettings', 'admin'),
'elements' => array(
'smtphosts' => array(
'type' => 'text',
'title' => get_string('emailsmtphosts', 'admin'),
'description' => get_string('emailsmtphostsdescription', 'admin'),
'defaultvalue' => get_config('smtphosts'),
'disabled' => in_array('smtphosts', $OVERRIDDEN),
'help' => true,
),
'smtpport' => array(
'type' => 'text',
'title' => get_string('emailsmtpport', 'admin'),
'description' => get_string('emailsmtpportdescription', 'admin'),
'defaultvalue' => get_config('smtpport'),
'disabled' => in_array('smtpport', $OVERRIDDEN),
'help' => true,
),
'smtpuser' => array(
'type' => 'text',
'title' => get_string('emailsmtpuser', 'admin'),
'description' => get_string('emailsmtpuserdescription', 'admin'),
'defaultvalue' => get_config('smtpuser'),
'disabled' => in_array('smtpuser', $OVERRIDDEN),
),
'smtppass' => array(
'type' => 'text',
'title' => get_string('emailsmtppass', 'admin'),
'defaultvalue' => get_config('smtppass'),
'disabled' => in_array('smtppass', $OVERRIDDEN),
),
'smtpsecure' => array(
'type' => 'select',
'title' => get_string('emailsmtpsecure', 'admin'),
'description' => get_string('emailsmtpsecuredescription', 'admin'),
'defaultvalue' => get_config('smtpsecure'),
'disabled' => in_array('smtpsecure', $OVERRIDDEN),
'options' => array(
'' => get_string('none', 'admin'),
'ssl' => get_string('emailsmtpsecuressl', 'admin'),
'tls' => get_string('emailsmtpsecuretls', 'admin'),
),
'help' => true,
),
),
),
'generalsettings' => array(
'type' => 'fieldset',
'collapsible' => true,
......@@ -490,7 +540,7 @@ function siteoptions_submit(Pieform $form, $values) {
'showselfsearchsideblock', 'searchusernames', 'showtagssideblock',
'tagssideblockmaxtags', 'country', 'viewmicroheaders', 'userscanchooseviewthemes',
'remoteavatars', 'userscanhiderealnames', 'antispam', 'spamhaus', 'surbl', 'anonymouscomments', 'disableexternalresources',
'proxyaddress', 'proxyauthmodel', 'proxyauthcredentials',
'proxyaddress', 'proxyauthmodel', 'proxyauthcredentials', 'smtphosts', 'smtpport', 'smtpuser', 'smtppass', 'smtpsecure',
'homepageinfo', 'showonlineuserssideblock', 'registerterms', 'allowmobileuploads',
'creategroups', 'createpublicgroups', 'allowgroupcategories', 'wysiwyg',
);
......
......@@ -372,6 +372,20 @@ $string['proxyauthmodelset'] = 'Proxy authentication model has been set';
$string['proxyauthcredentials'] = 'Proxy credentials';
$string['proxyauthcredentialsdescription'] = 'Enter the credentials required for your proxy to authenticate your web server in <em>username:password</em> format';
$string['proxyauthcredntialsset'] = 'Proxy authentication credentials set';
$string['emailsettings'] = 'Email settings';
$string['emailsmtphosts'] = 'SMTP Host';
$string['emailsmtphostsdescription'] = 'SMTP server to be used for mail sending, e.g. <em>smtp1.example.com</em>';
$string['emailsmtpport'] = 'SMTP Port';
$string['emailsmtpportdescription'] = 'Specify port number if SMTP server uses port different from 25';
$string['emailsmtpuser'] = 'User';
$string['emailsmtpuserdescription'] = 'If SMTP server requires authentication, enter user credentials in the corresponding fields';
$string['emailsmtppass'] = 'Pass';
$string['emailsmtpsecure'] = 'SMTP Encryption';
$string['emailsmtpsecuredescription'] = 'If the SMTP server supports encryption, enable it here.';
$string['emailsmtpsecuressl'] = 'SSL';
$string['emailsmtpsecuretls'] = 'TLS';
// Upload CSV and CSV errors
......
<h3>Site name</h3>
<p>As the name of your Mahara installation, the site name is shown in certain places around the site, as well as in system generated messages.</p>
<p>This field may be disabled if overridden by a setting in your config.php file.</p>
\ No newline at end of file
<h3>SMTP Host</h3>
<p>If you want to force Mahara to use a specific SMTP server instead of the system one, enter its hostname here.</p>
<p>It is possible to specify more than one host by separating them with semicolons, e.g. <em>smtp1.example.com;smtp2.example.com</em>, but keep in mind that all other settings (e.g. authentication credentials and port numbers) will apply to all listed servers. It is not possible to specify different credentials for each server in this list. This feature is useful when SMTP host authentication is not required or you list different frontends for the same mail server in which case other settings will work.</p>
<p>This field may be disabled if overridden by a setting in your config.php file.</p>
\ No newline at end of file
<h3>SMTP Port</h3>
<p>If SMTP server uses a port number different from 25, you may specify it here.</p>
<p>When encryption is enabled the default ports are 465 for SSL and 587 for TLS. You only need to specify a port number if it's different from these. Check the correct settings with your mail service provider.</p>
<p>This field may be disabled if overridden by a setting in your config.php file.</p>
\ No newline at end of file
<h3>SMTP Encryption</h3>
<p>If the SMTP server supports encryption, enable it here.</p>
<p>When encryption is enabled the default ports are 465 for SSL and 587 for TLS. If your settings are different from default make sure that the port setting is correct. Check correct settings with your mail service provider.</p>
<p>This field may be disabled if overridden by a setting in your config.php file.</p>
\ No newline at end of file
......@@ -28,6 +28,7 @@
defined('INTERNAL') || die();
function xmldb_core_upgrade($oldversion=0) {
global $SESSION;
ini_set('max_execution_time', 120); // Let's be safe
raise_memory_limit('256M');
......@@ -2276,5 +2277,15 @@ function xmldb_core_upgrade($oldversion=0) {
);
}
if ($oldversion < 2011042000) {
// Create empty variables in database for email configuration
set_config('smtphosts', '');
set_config('smtpport', '');
set_config('smtpuser', '');
set_config('smtppass', '');
set_config('smtpsecure', '');
$SESSION->add_info_msg('Email settings now can be configured via Site settings, however they may be overriden by those set in the config file. If you have no specific reason to use config file email configuration, please consider moving them to Site settings area.');
}
return $status;
}
......@@ -573,6 +573,13 @@ function core_postinst() {
set_config('installation_time', $now);
set_config('stats_installation_time', $now);
// Pre-define SMTP settings
set_config('smtphosts', '');
set_config('smtpport', '');
set_config('smtpuser', '');
set_config('smtppass', '');
set_config('smtpsecure', '');
// PostgreSQL supports indexes over functions of columns, MySQL does not.
// We make use if this if we can
if (is_postgres()) {
......
......@@ -348,6 +348,15 @@ function email_user($userto, $userfrom, $subject, $messagetext, $messagehtml='',
$mail->Password = get_config('smtppass');
$mail->SMTPSecure = get_config('smtpsecure');
$mail->Port = get_config('smtpport');
if (get_config('smtpsecure') && !get_config('smtpport')) {
// Encrypted connection with no port. Use default one.
if (get_config('smtpsecure') == 'ssl') {
$mail->Port = 465;
}
elseif (get_config('smtpsecure') == 'tls') {
$mail->Port = 587;
}
}
}
}
......
......@@ -28,7 +28,7 @@
defined('INTERNAL') || die();
$config = new StdClass;
$config->version = 2011041800;
$config->version = 2011042000;
$config->release = '1.4.0alpha2dev';
$config->minupgradefrom = 2008040200;
$config->minupgraderelease = '1.0.0 (release tag 1.0.0_RELEASE)';
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment