Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support StartTLS for SMTP autoconfiguration #3

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Installation

### Apache Webserver

You need an Apache webserver with PHP5 preconfigures. You can then configure your Virtual Host like this
You need an Apache webserver with (at least) PHP 7.3 preconfigured. You can then configure your Virtual Host like this

```
<VirtualHost *:443>
Expand Down
19 changes: 14 additions & 5 deletions autodiscover.xml.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
$xml = str_replace("%TTL%", $config['ttl'], $xml);


$xml = str_replace("%SERVER/SMTP/SSL_ON%", isOnOrOff($config['server']['smtp']['socket'] == "SSL"), $xml);
$xml = str_replace("%SERVER/SMTP/ENCRYPTION%", str_replace("STARTTLS", "TLS", $config['server']['smtp']['socket']), $xml);

$xml = str_replace("%SERVER/IMAP/SSL_ON%", isOnOrOff($config['server']['imap']['socket'] == "SSL"), $xml);

$xml = str_replace("%SERVER/IMAP/DOMAIN_REQUIRED%", isOnOrOff($config['server']['domain_required']), $xml);
Expand Down Expand Up @@ -55,16 +56,24 @@ function isOnOrOff ($value) {
}

function loadConfig () {
return json_decode(implode('', file('settings.json')), true);
$content = file_get_contents('settings.json');
if ($content === FALSE) {
throw new Exception('Error reading settings.json.');
}
return json_decode($content, true, 512, JSON_THROW_ON_ERROR);
}

function loadTemplate ($file) {
return implode("",file($file));
$content = file_get_contents($file);
if ($content === FALSE) {
throw new Exception('Error reading template file.');
}
return $content;
}

function determineTemplateFile () {

$template = array_key_exists('template', $_GET) ? $_GET['template'] : null;
$template = $_GET['template'] ?? null;

switch($template) {

Expand All @@ -84,7 +93,7 @@ function determineTemplateFile () {

function getRequestEmail () {

$email = array_key_exists('email', $_GET) ? $_GET['email'] : null;
$email = $_GET['email'] ?? null;
return filter_var($email, FILTER_VALIDATE_EMAIL);

}
Expand Down
2 changes: 1 addition & 1 deletion mail/autodiscover.xml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ If this value is true, then the SMTP server requires that email be downloaded be
<Port>%SERVER/SMTP/PORT%</Port>
<DomainRequired>%SERVER/SMTP/DOMAIN_REQUIRED%</DomainRequired>
<SPA>off</SPA>
<SSL>%SERVER/SMTP/SSL_ON%</SSL>
<Encryption>%SERVER/SMTP/ENCRYPTION%</Encryption>
<AuthRequired>on</AuthRequired>
<UsePOPAuth>on</UsePOPAuth>
<SMTPLast>off</SMTPLast>
Expand Down