add simple smtp-settings test-page, fixes #464
Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
@@ -290,3 +290,68 @@ if ($page == 'overview' && $userinfo['change_serversettings'] == '1') {
|
||||
}
|
||||
eval("echo \"" . getTemplate("settings/integritycheck") . "\";");
|
||||
}
|
||||
elseif ($page == 'testmail')
|
||||
{
|
||||
if (isset($_POST['send']) && $_POST['send'] == 'send')
|
||||
{
|
||||
$test_addr = isset($_POST['test_addr']) ? $_POST['test_addr'] : null;
|
||||
|
||||
/**
|
||||
* Initialize the mailingsystem
|
||||
*/
|
||||
$testmail = new PHPMailer(true);
|
||||
$testmail->CharSet = "UTF-8";
|
||||
|
||||
if (Settings::Get('system.mail_use_smtp')) {
|
||||
$testmail->isSMTP();
|
||||
$testmail->Host = Settings::Get('system.mail_smtp_host');
|
||||
$testmail->SMTPAuth = Settings::Get('system.mail_smtp_auth') == '1' ? true : false;
|
||||
$testmail->Username = Settings::Get('system.mail_smtp_user');
|
||||
$testmail->Password = Settings::Get('system.mail_smtp_passwd');
|
||||
if (Settings::Get('system.mail_smtp_usetls')) {
|
||||
$testmail->SMTPSecure = 'tls';
|
||||
}
|
||||
$testmail->Port = Settings::Get('system.mail_smtp_port');
|
||||
}
|
||||
|
||||
$_mailerror = false;
|
||||
if (PHPMailer::ValidateAddress(Settings::Get('panel.adminmail')) !== false) {
|
||||
// set return-to address and custom sender-name, see #76
|
||||
$testmail->SetFrom(Settings::Get('panel.adminmail'), Settings::Get('panel.adminmail_defname'));
|
||||
if (Settings::Get('panel.adminmail_return') != '') {
|
||||
$testmail->AddReplyTo(Settings::Get('panel.adminmail_return'), Settings::Get('panel.adminmail_defname'));
|
||||
}
|
||||
|
||||
try {
|
||||
$testmail->Subject = "Froxlor Test-Mail";
|
||||
$mail_body = "Yay, this worked :)";
|
||||
$testmail->AltBody = $mail_body;
|
||||
$testmail->MsgHTML(str_replace("\n", "<br />", $mail_body));
|
||||
$testmail->AddAddress($test_addr);
|
||||
$testmail->Send();
|
||||
} catch(phpmailerException $e) {
|
||||
$mailerr_msg = $e->errorMessage();
|
||||
$_mailerror = true;
|
||||
} catch (Exception $e) {
|
||||
$mailerr_msg = $e->getMessage();
|
||||
$_mailerror = true;
|
||||
}
|
||||
|
||||
if (!$_mailerror) {
|
||||
// success
|
||||
$mail->ClearAddresses();
|
||||
standard_success('testmailsent', '', array('filename' => 'admin_settings.php', 'page' => 'testmail'));
|
||||
}
|
||||
} else {
|
||||
// invalid sender e-mail
|
||||
$mailerr_msg = "Invalid sender e-mail address: ".Settings::Get('panel.adminmail');
|
||||
$_mailerror = true;
|
||||
}
|
||||
}
|
||||
|
||||
$mail_smtp_user = Settings::Get('system.mail_smtp_user');
|
||||
$mail_smtp_host = Settings::Get('system.mail_smtp_host');
|
||||
$mail_smtp_port = Settings::Get('system.mail_smtp_port');
|
||||
|
||||
eval("echo \"" . getTemplate("settings/testmail") . "\";");
|
||||
}
|
||||
|
||||
@@ -313,6 +313,10 @@ return array(
|
||||
array(
|
||||
'url' => 'admin_message.php?page=message',
|
||||
'label' => $lng['admin']['message']
|
||||
),
|
||||
array(
|
||||
'url' => 'admin_settings.php?page=testmail',
|
||||
'label' => $lng['admin']['testmail']
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
@@ -2078,3 +2078,5 @@ $lng['serversettings']['nssextrausers']['title'] = 'Use libnss-extrausers instea
|
||||
$lng['serversettings']['nssextrausers']['description'] = 'Do not read users from the database but from files. Please only activate if you have already gone through the required configuration steps (system -> libnss-extrausers).<br><strong class="red">For Debian/Ubuntu only (or if you have compiled libnss-extrausers yourself!)</strong>';
|
||||
$lng['admin']['domain_http2']['title'] = 'HTTP2 support';
|
||||
$lng['admin']['domain_http2']['description'] = 'See <a target="_blank" href="https://en.wikipedia.org/wiki/HTTP/2">Wikipedia</a> for a detailed explanation of HTTP2';
|
||||
$lng['admin']['testmail'] = 'SMTP test';
|
||||
$lng['success']['testmailsent'] = 'Test mail sent successfully';
|
||||
|
||||
@@ -1729,3 +1729,5 @@ $lng['serversettings']['nssextrausers']['title'] = 'Verwende libnss-extrausers a
|
||||
$lng['serversettings']['nssextrausers']['description'] = 'Lese Benutzer nicht direkt aus der Datenbank sondern über Dateien, bitte nur aktivieren, wenn die entsprechende Konfiguration vorgenommen wurde (System -> libnss-extrausers).<br><strong class="red">Nur für Debian/Ubuntu (oder wenn libnss-extrausers manuell kompiliert wurde!)</strong>';
|
||||
$lng['admin']['domain_http2']['title'] = 'HTTP2 Unterstützung';
|
||||
$lng['admin']['domain_http2']['description'] = 'Siehe <a target="_blank" href="https://de.wikipedia.org/wiki/Hypertext_Transfer_Protocol#HTTP.2F2">Wikipedia</a> für eine ausführliche Beschreibung von HTTP2';
|
||||
$lng['admin']['testmail'] = 'SMTP Test';
|
||||
$lng['success']['testmailsent'] = 'Test E-Mail erfolgreich gesendet';
|
||||
|
||||
48
templates/Sparkle/admin/settings/testmail.tpl
vendored
Normal file
48
templates/Sparkle/admin/settings/testmail.tpl
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
$header
|
||||
<article>
|
||||
<header>
|
||||
<h2>
|
||||
<img src="templates/{$theme}/assets/img/icons/email_edit_big.png" alt="" />
|
||||
{$lng['admin']['testmail']}
|
||||
</h2>
|
||||
</header>
|
||||
|
||||
<if !empty($_mailerror)>
|
||||
<div class="messagewrapperfull">
|
||||
<div class="warningcontainer bradius">
|
||||
<div class="warningtitle">{$lng['admin']['warning']}</div>
|
||||
<div class="warning">{$mailerr_msg}</div>
|
||||
</div>
|
||||
</div>
|
||||
</if>
|
||||
|
||||
<section>
|
||||
<table class="full">
|
||||
<tr>
|
||||
<th>{$lng['serversettings']['mail_smtp_user']}</th>
|
||||
<th>Host</th>
|
||||
<th>Port</th>
|
||||
<th>SMTP Auth</th>
|
||||
<th>TLS</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{$mail_smtp_user}</td>
|
||||
<td>{$mail_smtp_host}</td>
|
||||
<td>{$mail_smtp_port}</td>
|
||||
<td><img src="templates/{$theme}/assets/img/icons/<if Settings::Get('system.mail_use_smtp') == '1'>button_ok<else>cancel</if>.png" alt="" /></td>
|
||||
<td><img src="templates/{$theme}/assets/img/icons/<if Settings::Get('system.mail_smtp_usetls') == '1'>button_ok<else>cancel</if>.png" alt="" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
<br>
|
||||
<form action="{$linker->getLink(array('section' => 'settings'))}" method="post" enctype="application/x-www-form-urlencoded">
|
||||
<input type="hidden" name="s" value="$s" />
|
||||
<input type="hidden" name="page" value="$page" />
|
||||
<input type="hidden" name="action" value="$action" />
|
||||
<input type="hidden" name="send" value="send" />
|
||||
|
||||
<input type="text" name="test_addr" id="test_addr" placeholder="test address" />
|
||||
<input type="submit" value="Test">
|
||||
</form>
|
||||
</section>
|
||||
</article>
|
||||
$footer
|
||||
Reference in New Issue
Block a user