Commit a59498fc authored by mcramer's avatar mcramer

Implemented FS#2383 - SMTP function for all outgoing ispconfig mailer

parent 5e4f60c7
......@@ -39,6 +39,28 @@ class functions {
if($conf['demo_mode'] == true) $app->error("Mail sending disabled in demo mode.");
$app->uses('getconf,ispcmail');
$mail_config = $app->getconf->get_global_config('mail');
if($mail_config['smtp_enabled'] == 'y') {
$mail_config['use_smtp'] = true;
$app->ispcmail->setOptions($mail_config);
}
$app->ispcmail->setSender($from);
$app->ispcmail->setSubject($subject);
$app->ispcmail->setMailText($text);
if($filepath != '') {
if(!file_exists($filepath)) $app->error("Mail attachement does not exist ".$filepath);
$app->ispcmail->readAttachFile($filepath);
}
if($cc != '') $app->ispcmail->setHeader('Cc', $cc);
if($bcc != '') $app->ispcmail->setHeader('Bcc', $bcc);
$app->ispcmail->send($to);
$app->ispcmail->finish();
/* left in here just for the case...
if($filepath != '') {
if(!file_exists($filepath)) $app->error("Mail attachement does not exist ".$filepath);
......@@ -83,7 +105,7 @@ class functions {
$subject = "=?utf-8?B?".base64_encode($subject)."?=";
mail($to, $subject, $text, $header);
}
*/
return true;
}
......
This diff is collapsed.
......@@ -220,6 +220,50 @@ $form["tabs"]['mail'] = array (
'width' => '30',
'maxlength' => '255'
),
'smtp_enabled' => array (
'datatype' => 'VARCHAR',
'formtype' => 'CHECKBOX',
'default' => 'n',
'value' => array(0 => 'n',1 => 'y')
),
'smtp_host' => array (
'datatype' => 'VARCHAR',
'formtype' => 'TEXT',
'default' => '',
'value' => '',
'width' => '30',
'maxlength' => '255'
),
'smtp_port' => array (
'datatype' => 'VARCHAR',
'formtype' => 'TEXT',
'default' => '25',
'value' => '',
'width' => '30',
'maxlength' => '255'
),
'smtp_user' => array (
'datatype' => 'VARCHAR',
'formtype' => 'TEXT',
'default' => '',
'value' => '',
'width' => '30',
'maxlength' => '255'
),
'smtp_pass' => array (
'datatype' => 'VARCHAR',
'formtype' => 'TEXT',
'default' => '',
'value' => '',
'width' => '30',
'maxlength' => '255'
),
'smtp_crypt' => array (
'datatype' => 'VARCHAR',
'formtype' => 'CHECKBOX',
'default' => 'n',
'value' => array(0 => 'n',1 => 'y')
),
##################################
# ENDE Datatable fields
##################################
......
......@@ -29,4 +29,11 @@ $wb['admin_mail_txt'] = 'Administrator E-Mail';
$wb['monitor_key_txt'] = 'Monitor-Passwort';
$wb['admin_name_txt'] = 'Name des Administrators';
$wb['maintenance_mode_txt'] = 'Wartungsmodus';
$wb['smtp_enabled_txt'] = 'SMTP zum System-Mailversand nutzen';
$wb['smtp_host_txt'] = 'SMTP Server';
$wb['smtp_port_txt'] = 'SMTP Port';
$wb['smtp_user_txt'] = 'SMTP User';
$wb['smtp_pass_txt'] = 'SMTP Passwort';
$wb['smtp_crypt_txt'] = 'SSL/TLS verschlüsselte Verbindung für SMTP';
?>
......@@ -29,4 +29,10 @@ $wb['admin_mail_txt'] = 'Administrator\'s e-mail';
$wb["monitor_key_txt"] = 'Monitor keyword';
$wb['admin_name_txt'] = 'Administrator\'s name';
$wb['maintenance_mode_txt'] = 'Maintenance Mode';
$wb['smtp_enabled_txt'] = 'Use SMTP to send system mails';
$wb['smtp_host_txt'] = 'SMTP host';
$wb['smtp_port_txt'] = 'SMTP port';
$wb['smtp_user_txt'] = 'SMTP user';
$wb['smtp_pass_txt'] = 'SMTP password';
$wb['smtp_crypt_txt'] = 'Use SSL/TLS encrypted connection for SMTP';
?>
......@@ -39,6 +39,34 @@
<label for="admin_name">{tmpl_var name='admin_name_txt'}</label>
<input name="admin_name" id="admin_name" value="{tmpl_var name='admin_name'}" size="30" maxlength="255" type="text" class="textInput" />
</div>
<div class="ctrlHolder">
<p class="label">{tmpl_var name='smtp_enabled_txt'}</p>
<div class="multiField">
{tmpl_var name='smtp_enabled'}
</div>
</div>
<div class="ctrlHolder">
<label for="smtp_host">{tmpl_var name='smtp_host_txt'}</label>
<input name="smtp_host" id="smtp_host" value="{tmpl_var name='smtp_host'}" size="30" maxlength="255" type="text" class="textInput" />
</div>
<div class="ctrlHolder">
<label for="smtp_port">{tmpl_var name='smtp_port_txt'}</label>
<input name="smtp_port" id="smtp_port" value="{tmpl_var name='smtp_port'}" size="30" maxlength="255" type="text" class="textInput" />
</div>
<div class="ctrlHolder">
<label for="smtp_user">{tmpl_var name='smtp_user_txt'}</label>
<input name="smtp_user" id="smtp_user" value="{tmpl_var name='smtp_user'}" size="30" maxlength="255" type="text" class="textInput" />
</div>
<div class="ctrlHolder">
<label for="smtp_pass">{tmpl_var name='smtp_pass_txt'}</label>
<input name="smtp_pass" id="smtp_pass" value="{tmpl_var name='smtp_pass'}" size="30" maxlength="255" type="text" class="textInput" />
</div>
<div class="ctrlHolder">
<p class="label">{tmpl_var name='smtp_crypt_txt'}</p>
<div class="multiField">
{tmpl_var name='smtp_crypt'}
</div>
</div>
</fieldset>
<input type="hidden" name="id" value="{tmpl_var name='id'}">
......
......@@ -50,7 +50,7 @@ if(isset($_POST['username']) && $_POST['username'] != '' && $_POST['email'] != '
$email = $app->db->quote($_POST['email']);
$client = $app->db->queryOneRecord("SELECT * FROM client WHERE username = '$username' AND email = '$email'");
if($client['client_id'] > 0) {
$new_password = $app->auth->get_random_password();
$new_password_encrypted = $app->auth->crypt_password($new_password);
......@@ -61,7 +61,17 @@ if(isset($_POST['username']) && $_POST['username'] != '' && $_POST['email'] != '
$app->db->query("UPDATE client SET password = '$new_password_encrypted' WHERE username = '$username'");
$app->tpl->setVar("message",$wb['pw_reset']);
mail($client['email'],$wb['pw_reset_mail_title'],$wb['pw_reset_mail_msg'].$new_password);
$app->uses('getconf,ispcmail');
$mail_config = $app->getconf->get_global_config('mail');
if($mail_config['smtp_enabled'] == 'y') {
$mail_config['use_smtp'] = true;
$app->ispcmail->setOptions($mail_config);
}
$app->ispcmail->setSender($mail_config['admin_mail'], $mail_config['admin_name']);
$app->ispcmail->setSubject($wb['pw_reset_mail_title']);
$app->ispcmail->setMailText($wb['pw_reset_mail_msg'].$new_password);
$app->ispcmail->send(array($client['contact_name'] => $client['email']));
$app->ispcmail->finish();
$app->plugin->raiseEvent('password_reset',true);
......@@ -74,7 +84,6 @@ if(isset($_POST['username']) && $_POST['username'] != '' && $_POST['email'] != '
}
$app->tpl_defaults();
$app->tpl->pparse();
......
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